Why is my script not updating my db table ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeddiki
    Contributor
    • Jan 2009
    • 290

    Why is my script not updating my db table ?

    Hi,
    I am trying to run my simple analysis script on an existing database table that I have.

    I have increased my php time out to 5 minutes and the same with
    my apache server config file - 300 seconds, so should be plenty of time.

    My script is below.
    If there is any way I can speed it up, that would be useful to know ;-)

    The echo in the script, only display after about 5 minutes of waiting
    even though I have exited after only processing 300 records !

    Here is the last few lines of the output:


    299 ) Processing Clickbankid: CANDOCO1
    Written new row in cb_main: CANDOCO1, Business to Business, A+ Teachers' Interview Edge.
    Written new row in cb_data: CANDOCO1, 0, 1.08
    300 ) Processing Clickbankid: PDFPRO2
    Written new row in cb_main: PDFPRO2, Business to Business, Create, View, Write And Print PDF.
    Written new row in cb_data: PDFPRO2, 0, 2.36

    This is my script:


    Code:
    while($row = mysql_fetch_assoc($result)){
        $the_id = $row['id'];
            
    echo "<br>$ctr ) Processing Clickbankid: $the_id";         
            
        $sql_main = "SELECT Mid FROM cb_main WHERE Mid = '$the_id' ";
        $result_main = mysql_query($sql_main)
                        or die("could not FIND ID in cb_main.". mysql_error()); 
            
        $num = mysql_num_rows($result_main);
            
        if ($num == 0 ) {     // If the product is NEW
        extract($row);
           $sql_ins = "INSERT INTO cb_main
        (Mcb_date, Mday_no, Mid, Mcat, Mpop, Mtitle, Mdescrip, Mrecurr, Mgrav, Mearn, Mpercent, Mtotearn, Mrebill, Mrefer, Mcomm, Mthis_ave, Mlast_ave)
        VALUES 
        ('$cb_date', '$day_no', '$id', '$cat', '$pop', '$title', '$descrip', '$recurr', '$grav', '$earn', '$percent', '$totearn', '$rebill', '$refer', '$comm','$grav','$grav' )";
                
        $result_ins = mysql_query($sql) or die("could not execute INSERT to cb_main.". mysql_error());           
            
    echo "<br>Written new row in cb_main: $id, $cat, $title";         
            
           $sql_ins = "INSERT INTO cb_data
        (cb_date, day_no,id, pop, grav, rebill, this_ave, last_ave)
        VALUES 
         ('$cb_date', '$day_no', '$id', '$pop', '$grav', '$rebill', '$grav','$grav' )";
                
        $result_ins = mysql_query($sql) or die("could not execute INSERT to cb_data.". mysql_error());           
    
    echo "<br>Written new row in cb_data: $id, $day_no, $grav";         
            
        }
    $ctr++; 
    if ( $ctr > 300 ) exit;
    } // end while
    echo "<br>Finished";
    ?>
    Pretty basic script, but it does NOT update the two tables.

    When I check their contents - there is zero rows :(

    Can anyone see what I did wrong ?
Working...