为什么MySQL会导致语法错误?

时间:2013-05-03 15:00:43

标签: php mysql syntax-error

这是我的代码:

$query = "SELECT * directory WHERE id ='$comId'";

echo $query;

$com_result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_assoc($com_result)) {  // While I am finding agents.

以下是$ query等于:

SELECT * directory WHERE id ='4'

以下是我之后得到的内容:

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 'directory WHERE id ='4'' at line 1

1 个答案:

答案 0 :(得分:9)

你只是缺少FROM条款。

SELECT * FROM directory WHERE id ='4'