This error usually means the query failed. Try adding this to the script (after $r = mysql_query($q))
This will tell you what's wrong about the query, which is probably the problem.Code:echo mysql_error();
Here is line 115 of index.php:Code:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/haslamx/public_html/vote/src/index.php on line 115
Can anyone tell me what I'm doing wrong? Help would be greatly appreciated, thank you!Code:<?php /** Display the results from the database **/ $q = "SELECT * FROM entries"; $r = mysql_query($q); >> Line 115 :if(mysql_num_rows($r)>0): //table is non-empty while($row = mysql_fetch_assoc($r)): $net_vote = $row['votes_up'] - $row['votes_down']; //this is the net result of voting up and voting down ?>![]()
This error usually means the query failed. Try adding this to the script (after $r = mysql_query($q))
This will tell you what's wrong about the query, which is probably the problem.Code:echo mysql_error();
Make sure your scripts handle errors properly. This means catching exceptions and testing return values (and throwing exceptions and returning error values, when appropriate, as the point an error is detected is often not the point it can be handled), and giving useful information in error messages without revealing sensitive information. Implement error handling early; it will help you in your development by letting you know what's failing and where.
Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Jon Skeet's and Eric Raymond's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.Misson, not Mission.