Wednesday, November 12, 2008

Question: How can we create a database using php and mysql?

Question: How can we create a database using php and mysql?

Answer: mysql_create_db()

Example:

$link = mysql_connect(’localhost’‚ ’mysql_user’‚ ’mysql_password’);

if (!$link)

    {

        die(’Could not connect: ’ . mysql_error());

    }

$sql = ’CREATE DATABASE my_db’;

if (mysql_query($sql‚ $link))

    {

        echo "Database my_db created successfully\n";

    }

else

    {

        echo ’Error creating database: ’ . mysql_error() . "\n";

    }

?>

No comments:

How to solve mysql ERROR 1118 (42000) Row size too large

  I had this issue with MYSQL 5.7 . The following worked althoug...