如何使用上一页的GET变量发送来恢复数据库行?
我试过这个:
$username = $_GET["username"];
$result = mysqli_query($con,"SELECT * FROM users
WHERE username=$username");
但它给了我错误
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /homepages/12/d441172468/htdocs/cmd/play/index.php on line 33
请帮忙!谢谢!
答案 0 :(得分:2)
每当您收到该错误时,您应立即添加此调试代码:
var_dump(mysqli_error());
除此之外,这是一个相当简单的例子,忽略了在变量周围加上引号。你还没有逃脱它,所以你邀请Bobby Tables ......
试试这个:
$result = mysqli_query($con,
"SELECT * FROM users WHERE username='"
.mysqli_real_escape_string($_GET['username'])."'");