/*这是可行的
$conn=mysql_connect('localhost','root','f3r5tqfp')ordie('Couldnotconnect'.mysql_error());echo'Connectedsuccessfully';if(mysql_query.../*这是可行的
$conn = mysql_connect('localhost','root','f3r5tqfp')or die('Could not connect ' .mysql_error());
echo 'Connected successfully';
if (mysql_query("create database my_db",$conn))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
}
?>
*/
当我修改成这样,mysql_query怎麼我把原先my_db转为形参就发生问题
Warning: mysql_query() expects parameter 2 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/dropDownMenu/css80.php on line 10
Error creating database:
$conn = mysql_connect('localhost','root','f3r5tqfp')or die('Could not connect ' .mysql_error());
echo 'Connected successfully';
function createDB($db)
if (mysql_query("create database $db",$conn))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
}
createDB('my_db');
?>
展开