我已经在phpmyadmin中创建了一个数据库。当我提交表单时,脚本应该在数据库中插入数据。但是,我收到错误“没有选择数据库”。 你能看看我的代码,看看你是否能找到我出错的地方。谢谢没有数据库选择的错误php mysql
$dbc = mysqli_connect('localhost','aliendatabase') or die('Error connecting to MySQL server.');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, ".
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysqli_query($dbc, $query)
or die(mysqli_error($dbc));
mysqli_close($dbc);
它没有密码 – user3602426 2014-10-02 11:57:20
mysqli_connect('localhost','root','','database_name');保持密码为空 – 2014-10-02 12:00:12
@ user3602426检查更新的答案 – 2014-10-02 12:01:20