Jump to content

Recommended Posts

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]
<?php
include('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 mind

This always happens, as soon as I see the reveiw the code when i post it. I see my issue.

Thanks anyway

Josh
Link to comment
https://forums.phpfreaks.com/topic/11713-finishing-script-then-erroring/
Share on other sites

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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.