错误PDOException:SQLSTATE [42000]

时间:2017-07-08 09:50:09

标签: php

我有2张桌子 一个是类别,另一个是工作。

类别表由2列id和category组成 和表作业有3列id category_id和salary

category_id告诉类别表中类别的ID号。 我想计算category_id为1的行数,然后打印检索到的值......

我的PHP代码

$c_id=1;
$query=$db->prepare('SELECT * FROM jobs WHERE category_id = :cid');
$query->bindValue(':cid',  $c_id, PDO::PARAM_INT);
$query->execute();
$result=$query->rowCount();

错误

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE category_id=1' at line 1 in C:\xampp\htdocs\EsserePro\job1.php:281 Stack trace: #0 C:\xampp\htdocs\EsserePro\job1.php(281): PDOStatement->execute() #1 {main} thrown

0 个答案:

没有答案
相关问题