1

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?

2
  • Could you specify the "an error on the last line" ? Commented May 26, 2011 at 9:36
  • Dont worry guys, i found the error - it was the comma in the sql statement. Commented May 26, 2011 at 9:39

1 Answer 1

5

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

try $query="SELECT PostSubject FROM postings";

Sign up to request clarification or add additional context in comments.

1 Comment

@Jason - no problem mate - I have been caught out like that on much simpler things (>.<)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.