这是我得到的错误......
Failed to prepare statement: (1064) 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 '?.Pages WHERE slug='?'' at line 1
这是我的代码...
require_once("../database/config.php");
$pageSlug = "home";
$db = new mysqli(_DB_HOST, _DB_USER, _DB_PASSWORD, _DB_NAME);
if ( $db->connect_errno ) {
echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
exit();
}
if ( !$selectQuery = $db->prepare("SELECT * FROM ?.Pages WHERE slug='?'") ) {
echo "Failed to prepare statement: (" . $db->errno . ") " . $db->error;
exit();
}
if ( !$selectQuery->bind_param("ss", _DB_NAME, $pageSlug) ) {
echo "Binding parameters failed: (" . $selectQuery->errno . ") " . $selectQuery->error;
exit();
}
if ( !$selectQuery->execute() ) {
echo "Exexute failed: (" . $selectQuery->errno . ") " . $selectQuery->error;
exit();
}
echo "<pre>I GOT HERE!</pre>";
exit();
../database/config.php
仅包含我在上面引用的全局变量(“_DB_NAME”等)。
我想我仍然只是围绕这些准备好的陈述事情而思考,并且真的不知道我做错了什么。
提前致谢!