duanheye7909
2011-05-26 09:35
浏览 45
已采纳

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

So this is what I have:

<?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); ?>

But its not working, when I try and run it gives me some error on the last line.

Any ideas?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dqb77047 2011-05-26 09:37
    最佳回答

    $query="SELECT PostSubject, FROM postings;"; is invalid sql

    try $query="SELECT PostSubject FROM postings";

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题