homchz Posted June 11, 2006 Share Posted June 11, 2006 This one is wierd. My script is running and updating my db, but I am getting an error afterward, and an unusual <br/> tag???The funtion inside of the class jobs[code]function pay_cron() { $sql = mysql_query("SELECT uid, gold, salary FROM p_users WHERE occupation != '0'")or die(mysql_error()); while($results = mysql_fetch_object($sql)) { $uid[] = $results->uid; $gold[] = $results->gold; $salary[] = $results->salary; $num = count($uid); for($i=0; $i<$num; $i++) { $pay = ($gold[$i]+$salary[$i]); $sql = mysql_query("UPDATE p_users SET gold = '$pay' WHERE uid = '$uid[$i]'")or die(mysql_error()); $update = mysql_query($sql); } } }[/code]How I am calling the funtion for testing:[code]<?phpinclude('classes/class_jobs.php');$daily_pay = new jobs;$daily_pay->pay_cron();?>[/code]Then I am getting this warning "after" the script excutes. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/flightfe/public_html/new/projects/pirate/source/classes/class_jobs.php on line 127[/quote]Line 126 & 127:[code]126: $sql = mysql_query("SELECT uid, gold, salary FROM p_users WHERE occupation != '0'")or die(mysql_error());127: while($results = mysql_fetch_object($sql))[/code]any thoughts??Edit: never mindThis always happens, as soon as I see the reveiw the code when i post it. I see my issue.Thanks anywayJosh Quote Link to comment https://forums.phpfreaks.com/topic/11713-finishing-script-then-erroring/ Share on other sites More sharing options...
joquius Posted June 11, 2006 Share Posted June 11, 2006 try running the sql query on the database outside the code..if it works there...weird because no strings in the query. You are connected to the db right? Quote Link to comment https://forums.phpfreaks.com/topic/11713-finishing-script-then-erroring/#findComment-44283 Share on other sites More sharing options...
homchz Posted June 11, 2006 Author Share Posted June 11, 2006 Yeah, I had to chave it to this[code]function pay_cron() { $sql = mysql_query("SELECT uid, gold, salary FROM p_users WHERE occupation != '0'")or die(mysql_error()); while($results = mysql_fetch_object($sql)) { $uid[] = $results->uid; $gold[] = $results->gold; $salary[] = $results->salary; $num = count($uid); } for($i=0; $i<$num; $i++) { $pay = ($gold[$i]+$salary[$i]); $sql = mysql_query("UPDATE p_users SET gold = '$pay' WHERE uid = '$uid[$i]'")or die(mysql_error()); $update = mysql_query($sql); } }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11713-finishing-script-then-erroring/#findComment-44284 Share on other sites More sharing options...
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.