我开发了一个页面,用户可以使用该页面搜索我的数据库中的各种数据,但不会显示任何内容.
没有错误或消息显示它只是刷新页面.
bind_param对我来说是新的,所以我觉得这可能是一个错误 - $stmt->bind_param('s', $name);
我已经与数据库进行了比较,所有表名和变量名都是正确的.
search.php中
prepare ("SELECT * FROM users WHERE Username = '$name'")) { $stmt->bind_param('s', $name); $stmt->execute(); $stmt->bind_result($personresult); $stmt->fetch(); print_r($personresult); } else { echo "Please enter a search query
"; } } else { echo "NOT SET!"; } ?>
显示错误
Warning: session_start(): Cannot send session cookie - headers already sent searchform.php:2 which is displayed underneath:
Search for people
Please enter the name you wish to search for
Or search people by category
DaMaGeX.. 5
我想它应该是这样的:
if ($stmt = $connection->prepare ("SELECT * FROM users WHERE Username = ?"))
有一个?作为占位符.
从这里的例子中得到它:http://php.net/manual/en/mysqli-stmt.bind-param.php
我想它应该是这样的:
if ($stmt = $connection->prepare ("SELECT * FROM users WHERE Username = ?"))
有一个?作为占位符.
从这里的例子中得到它:http://php.net/manual/en/mysqli-stmt.bind-param.php