PHP with MySQL Question

I keep getting the following error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/leeq/public_html/cronjob.php on line 12

For the script below

10: $ressa3 = mysql_query(“SELECT * FROM investment_hitory WHERE expired=‘no’”);
11: if ($the_day > $last_cronjob != 0) {
12: for ($vv = 0; $vv < mysql_num_rows($ressa3); $vv++) {
13: $exp = mysql_result($ressa3, $vv, “adate”);
14: $expire_day = strftime("%Y-%m-%d", strtotime("$exp + $getdays days"));
15: $usrid = mysql_result($ressa3, $vv, “usrid”);
16: $id = mysql_result($ressa3, $vv, “id”);
17: $amount = mysql_result($ressa3, $vv, “amount”);
18: $user = mysql_query(“SELECT * FROM user WHERE id=$usrid”);
19: $uemail = mysql_result($user, $usrid, “email”);
20: $users_name = mysql_result($user, $usrid, “name”);
21: $invest = mysql_result($user, $usrid, “invested”);
22: if ($expire_day <= $the_day) {
23: mysql_query(“UPDATE investment_history SET expired=‘yes’ WHERE id=$id”);
24: mysql_query(“UPDATE user SET invested=invested-$amount WHERE id=$usrid”);
25: mail($uemail, “$title Upgrade Expired!”, “Hello $users_name,nnYour $title Upgrade for the amount of $amount has just expired.nn$self_urlnnRegardsnn$title Admin”, $email_headers);
26: $message_ins = $message_ins . “Member: $usrid Ammount: $amountn”;
27: }
28: mail($private_sys_email, “$title Upgrade(s) Expired!”, “Hi $title System here…nnThe following account upgrades have expired:nn” . $message_ins, $email_headers);
29: }
30: }

Anyone know what the problem is?

Thanks
Lee

My guess would be you have something wrong with your query and its not returning any results.

Need to make sure you do error reporting…

$ressa3 = mysql_query(“SELECT * FROM investment_hitory WHERE expired=‘no’”) or die("Error Returning Results: " . mysql_error());

This will kill the script if it runs into an error and should display something like:

Error Returning Results: mysql sytax error near line…

Something like that anyway, oh just by looking at the query it looks as though you my have the table name wrong, just a guess though.

Sponsor our Newsletter | Privacy Policy | Terms of Service