여기mysqli prepared statements를 배우려고 시도합니다. 내가 도대체 뭘 잘못하고있는 겁니까?
가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"등을 참조하는 글로벌 변수를 포함 ... 내 코드의 여기 ...
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
내가지고있어 오류입니다 그리고).
나는 아직도이 준비된 문장 주위에 머리를 감싸고 있고 내가 잘못하고있는 것을 정말로 모른다고 생각한다. 사전에
감사합니다!
[PHP \ MYSQL 준비된 문] (http://stackoverflow.com/questions/16057356/php-mysql-prepared-statements) 가능한 중복 " – BlitZ