我有一個查詢在那裏我指望行,但它顯示這個錯誤..致命錯誤:未捕獲的異常「PDOException」有消息「SQLSTATE [42000]:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 'from=? AND to=?' at line 1' in C:\wamp\www\network\profile.php on line 38
(!) PDOException: SQLSTATE[42000]: Syntax error or access violation: 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 'from=? AND to=?' at line 1 in C:\wamp\www\network\profile.php on line 38
這裏是我的代碼:
$sql_check_friend = "SELECT COUNT(*) FROM connection_request WHERE from=:me AND";
$sql_check_friend .= "to=:friend";
$sth = $db->prepare($sql_check_friend);
$sth->bindParam(":me", $me);
$sth->bindParam(":friend", $pageuserid);
$sth->execute();
$count = $sth->fetchColumn();
if($count > 0){
echo "REQUEST SENT";
}else{
echo "NOT SENT";
}
我無法弄清楚什麼是錯的..
你在第一行缺少'';',在第二行缺少''''。 –
我在這裏打破了代碼..在我的編輯器它是在一行..我將編輯這一個雖然.. – user3184462