...

View Full Version : Only part of my table updates ???



jeddi
03-14-2010, 08:51 AM
Hi,

I am running a simple script to update one of my tables.

But for some reason, out of the 12,000 rows it only
processes the first 4,303 and I can not see any
reason why it stops :confused:


This is my simple script:



$log_file = "/home/my_path/a_log_URLs.txt";
$handle = fopen("$log_file", "wb");
//$today = $today-10800;
$logstamp = date('H:i:s l, j F Y', $today);

function write_log($content) {
global $handle;
fwrite($handle, $content);
}

function write_error($content) {
global $handle;
fwrite($handle, $content);
exit;
}

write_log("----------------------------------------------- \r\nNew record - Time Stamp: $logstamp \r\n");

$sql = "SELECT id FROM cb_update ORDER BY id";
$result = mysql_query($sql) or write_error("Could not SELECT id FROM cb_update".mysql_error()." \r\n");

$ctr = 1;
while($row = mysql_fetch_assoc($result)) {
$id = $row['id'];

$sql_ck = "SELECT prod_id FROM cb_urls WHERE prod_id = '$id'";
$result_ck = mysql_query($sql_ck) or write_error("Could not SELECT prod_id FROM cb_urls".mysql_error()." \r\n");
$num_ck = mysql_num_rows($result_ck);
if($num_ck == 0) {

$id = 'new'.$ctr;
$Db_url = 'url_test'.$ctr;
$Db_dom' = 'dom_test'.$ctr;

$sql_url_upt = "INSERT INTO cb_urls ( prod_id, url, dom ) VALUES ( '$id', '$Db_url', '$Db_dom' )";
result_url_upt = mysql_query($sql_url_upt) or die("could not UPDATE cb_urls". mysql_error());

write_log("$ctr ) $id, Url: $Db_url, Dom: $Db_dom \r\n");

}
else {
write_log("$ctr )$id Found \r\n");
}
$ctr++;
}
fclose($handle);


The end of my log is simply:

4300 )GENERATORS Found
4301 )GENETIC Found
4302 )GENTLEMANS Found
4303 )GENTLERAIN Found

When I ran the script the first time it also only
processed the first 4303 then stopped.

It does the same on re-run.

No errors are shown.

ALL the other rows have valid 'id' values.

Why does it stop ?
What could be the problem ?

Any ideas ?

Thanks



.

masterofollies
03-14-2010, 02:07 PM
It might be in your database. Could be like a smallint restriction on the ID, or also could be a processing limit. Script seems fine?

jeddi
03-14-2010, 06:15 PM
Thanks,
I ran the script using a different order and found that it
stopped on the same record.

Looked at the record - no problem !

So I deleted it :D

Script ran to end after that :)



.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum