我已經在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