这是我的users
桌子:
uid (main) | username | password
1 | Admin | "(actual password removed)"
2 | Dummy | "(another password removed)"
我的 MySQL 查询如下:
SELECT * FROM `users` WHERE username = "Admin"
我的 php 代码如下所示:
$con=@mysqli_connect("localhost","root","root","database");
$sql='SELECT * FROM `users` WHERE username = "Admin"';
mysqli_prepare($con, $sql);
mysqli_query($con, $sql);
mysqli_close($con);
如果我在 phpMyAdmin 中运行此代码,则它会成功返回第一行,但是如果我从我的 php 页面运行它,则会收到以下错误:
Fatal error: Problem preparing query (SELECT * FROM `users` WHERE username = "Admin") 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 '"Admin"'
我不明白有什么区别...