出於某種原因,我的查詢不起作用,但它以前做過。與PDO MySQL查詢問題
$stmt = $pdo->prepare('SELECT * FROM '.$table.' WHERE urlid = :used');
$stmt->execute(array(':used' => $fname));
$num = $stmt->rowCount();
if ($num == 1 OR $num > 1){
錯誤:
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 'WHERE urlid = ?' at line 1' in /Applications/XAMPP/xamppfiles/htdocs/fbc/urlid.php:100 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/fbc/urlid.php(100): PDO->prepare('SELECT * FROM ...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/fbc/urlid.php on line 100
究竟是如何不工作?發佈錯誤。 –
wha在'$ fname'中? –