开发者

Error when trying to retrieve data from MySQL database with PHP

开发者 https://www.devze.com 2023-03-08 17:24 出处:网络
So this is what I have: <?php $db_host = \"localhost\"; $db_username = \"root\"; $db_pass = \"\"; $db_name = \"OnlineBulletinBoardDB\";

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?


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

try $query="SELECT PostSubject FROM postings";

0

精彩评论

暂无评论...
验证码 换一张
取 消