出于某种原因,我的查询无法正常工作,但之前确实没有。
$stmt = $pdo->prepare('SELECT * FROM '.$table.' WHERE urlid = :used');
$stmt->execute(array(':used' => $fname));
$num = $stmt->rowCount();
if ($num == 1 OR $num > 1){
ERROR:
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
答案 0 :(得分:-2)
尝试将您的SQL查询更改为
$stmt = $pdo->prepare("SELECT * FROM $table WHERE urlid = :used");
并确保您的变量$ table已正确定义