私はmysqliを使ってコード化した家庭で働くことができますが、私の学校ではこれが有効になっていないので、今はクエリを実行できません。何が間違っているのですか?接続文/クエリを挿入するとどうなりますか?
!!!更新!!!
私は自宅のWebサイトに接続し、$ dbc内の接続と余分なフィールド(データベース名)を削除するだけで接続を再開し、エラーを取得しました。これは、接続からデータベース名を削除する前でも発生しました。だから私は、スクリプトは私が接続しているデータベースを知らないことに気づいた。これをどうすれば解決できますか?
ホーム(作品)
/* database connection */
$dbc = mysqli_connect('localhost', 'user', '9890667', 'zombies')
or die('Error Connecting to the MySQL Server');
/* insert query */
$query = "INSERT INTO zombie_sighted (first_name,last_name, when_it_happened, how_long, how_many, zombie_description, what_they_were_doing, fang_spotted, other, email) " .
"VALUES ('$first_name','$last_name','$when_it_happened','$how_long','$how_many','$zombie_description','$what_they_did','$fang_spotted','$other','$email')";
/* execute query */
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
学校(コネクトしかし、クエリが、今は動作しません)更新
$dbc = mysql_connect('shcool url', 'username, 'password')
or die('Error Connecting to the MySQL Server');
/* insert query */
$query = "INSERT INTO zombie_sighted (first_name,last_name, when_it_happened, how_long, how_many, zombie_description, what_they_were_doing, fang_spotted, other, email) " .
"VALUES ('$first_name','$last_name','$when_it_happened','$how_long','$how_many','$zombie_description','$what_they_did','$fang_spotted','$other','$email')";
/* execute query */
$result = mysql_query($dbc, $query)
or die('Error querying database.');
mysql_close($dbc);
あなたはコマンドラインを使ってmysqlに接続できますか? – Zimbabao
私はパテを使って、コマンドラインを使ってデータベーススクリプトをインポートすることもできます。 –
あなたが見るものが「データベースを照会している間違い」である場合、何が起こったのか分かりません。あなたは 'mysqli_error()'をどこかで呼び出す必要があります... – BoltClock