Good point smpdawg, I assumed that he was going to use the data returned, not just the row count.
You should also not use SELECT count(*), but SELECT count(unique_index_field) to save more "resources".
To answer the question though... Use the following:
Code: Select all
$query = "SELECT comment FROM comments, posts, users
WHERE comments.postID = posts.postID AND comments.firstname = users.firstname AND comments.postID=$postID";
// Show SQL Query
echo("Query=$query<hr />");
When you run the code you should now get the SQL query displayed. Is this what you were expecting ? If you run this command using SQL on the database (phpAdmin or whatever, not through your PHP code) does it work ?
If No then we need to track down why (at a guess the parameter is not set).
If Yes add this immediately after you set the $result:
Code: Select all
// Check here
if (!$result) die(mysql_error());
This should show any sql query errors and terminate the script. If no error result then the SQL query is wrong (should have failed when running the command through SQL) on the database itself.
All we are trying to do is narrow down the problem. Imagine the the code as being steps. Perform these steps in turn and verify the program has the data you expect.