尝试使用PHP从MySQL数据库检索数据时出错

时间:2011-05-26 09:35:06

标签: php mysql

所以这就是我所拥有的:

<?php

$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "OnlineBulletinBoardDB";

@mysql_connect("$db_host","$db_username","$db_pass") or die ("Could no connect to    MySQL");
@mysql_select_db("$db_name") or die ("No database");

$query="SELECT PostSubject, FROM postings;";

$result=mysql_query($query);

mysql_close();

?>

<H1>Post Subject</H1>

<?php echo mysql_num_rows($result); ?>

但它不起作用,当我尝试运行它时,在最后一行给出了一些错误。

有什么想法吗?

1 个答案:

答案 0 :(得分:5)

$query="SELECT PostSubject, FROM postings;";无效sql

尝试$query="SELECT PostSubject FROM postings";