bloodless2010 Posted January 16, 2013 Posted January 16, 2013 Okay I have a small problem: I get this error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/royal857/public_html/job.php on line 126 function job_promote() { global $ir,$c,$userid,$h; $getjobq = mysql_query("SELECT * FROM jobranks WHERE jrJOB={$ir['jobrank']}", $c); $getjob = mysql_fetch_array($getjobq); $queryjob = mysql_query("SELECT * FROM jobranks WHERE jrPAY > {$getjob['jrPAY']} AND jrSTRN <= {$ir['strength']} AND jrLABOURN <= {$ir['labour']} AND jrIQN <= {$ir['IQ']} AND jrJOB = {$ir['job']} ORDER BY jrPAY DESC LIMIT 1", $c); $jobthing = mysql_num_rows($queryjob); if($jobthing > 0) { $r = mysql_fetch_array($queryjob); mysql_query("UPDATE users SET jobrank={$r['jrID']} WHERE userid=$userid", $c); print "Congratulations, you have been promoted to {$r['jrNAME']}<br /> <a href='job.php'>> Back</a>"; } else { print "Sorry, you cannot be promoted at this time.<br /> <a href='job.php'>> Back</a>"; } } Line #126 is $jobthing = mysql_num_rows($queryjob); Thank you! Quote
sniko Posted January 16, 2013 Posted January 16, 2013 Debug. Go to phpmyadmin Click your table Click SQL Run the following, and paste result SELECT * FROM jobranks WHERE jrPAY > 0 AND jrSTRN <= 10 AND jrLABOURN <= 10 AND jrIQN <= 10 AND jrJOB =1 ORDER BY jrPAY DESC LIMIT 1 However, I'd construct the query to something like the following; SELECT * FROM `jobranks` WHERE (`jrPAY` > 0) AND (`jrSTRN` <= 10) AND (`jrLABOURN` <= 10) AND (`jrIQN` <= 10) AND (`jrJOB` =1) ORDER BY `jrPAY` DESC LIMIT 1 Also, do you need the wildcard? (*) Quote
bloodless2010 Posted January 16, 2013 Author Posted January 16, 2013 I don't really need the (*) but I just used it to try and make it work just incase that was it, forgot to mention that it only gives the error if you're the highest jobrank that you can get, SELECT * FROM jobranks WHERE jrPAY > 0 AND jrSTRN <= 10 AND jrLABOURN <= 10 AND jrIQN <= 10 AND jrJOB =1 ORDER BY jrPAY DESC LIMIT 1 returns Showing rows 1 - 0 ( 1 total, Query took 0.0004 sec) [jrPAY: 250 - 250] jrID jrNAME jrJOB jrPAY jrIQG jrLABOURG jrSTRG jrIQN jrLABOURN jrSTRN 1 Recruit 1 250 1 2 4 5 10 10 The second query returns the same thing. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.