我的数据库公共文件
<?php
$link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error());  
mysql_select_db("zhubao") or die("Could not select database");
$sqlstr="select * form user ";
$result = mysql_query($sqlstr) or die("Query failed : " . mysql_error());
mysql_free_result($result);
mysql_close($link);
?>
报错:
Query failed : 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 'form user' at line 1
请问怎么解决?

解决方案 »

  1.   

    Query failed : 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 'form user' at line 1
    ---------------------------------
    这么简单得错误都调试不出来么?,已经用单引号引起来了.
    'form user'! 应该是'from user'!
      

  2.   

    嗯,form 和 from 容易错
    另外一个容易错的就是数据库中的关键词 key不能做表明,如果做了,在sql语句中应该写成[key]
    很多错误是简单,但自己没注意到的,加油学