我只是學習PHP的上下文中的SQL,我有問題。 我做了這個代碼:SQL錯誤#1064 - PHP代碼
error_reporting(E_ALL);
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_BENUTZER', 'dvd');
define ('MYSQL_KENNWORT', 'abc');
define ('MYSQL_DATENBANK', 'benutzer');
#establish connection
$db_link = mysqli_connect (
MYSQL_HOST,
MYSQL_BENUTZER,
MYSQL_KENNWORT,
MYSQL_DATENBANK
);
$abfrage = "USE benutzer; SELECT `code`, `used` FROM `keys` WHERE `code` LIKE '$key'";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis)
OR die("Error: $ergebnis <br>".mysql_error());
我想有一個時間密鑰的系統和釋我混帳的數據,如果他們已經使用尋找。 有了這個代碼,PHP顯示我的錯誤:
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\xampp\htdocs\dvds\administration\auth.php on line 8
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\dvds\administration\auth.php on line 9
Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT `key`, `used` FROM `keys` WHERE `key` LIKE 'KjAvkSpUwJCdNjfTEDfRDUrVmGXBH' at line 1*
Please help me!!
的mysql_query只接受一次一個查詢時,您已經確定在連接數據庫,取出使用benutzer,拋開過時的功能 – Mihai
請使用mysqli_query。所有的mysql函數都被棄用,請使用mysqli代替 – Mramaa
MySQLi:http://php.net/manual/en/book.mysqli.php PDO:http://php.net/manual/en/book.pdo.php – sodawillow