troubleshooting Question

Linux box killing my script...

Avatar of blink10
blink10 asked on
LinuxPHP
6 Comments1 Solution289 ViewsLast Modified:
I trying to run a while loop to process my product's records.

However....I have about 8 million records and every time I try to run it, it just does nothing for 3 minutes and then just says killed.

Why does this while loop kill it? Below I have the code will is causing the problems....ideas on how to modify it? (when i limit it to 10 it runs ok)

I have a feeling it a memory issue, by why cant it process this number of records?
//LINKSHARE - ALL 

$resultp = mysql_query("SELECT * FROM LinkshareProducts WHERE P_Id<>''");

while($row = mysql_fetch_array($resultp)) {

$UPC=$row['UPC'];

//special scripting to get isbn number


$tt=$row['ClassID'];
if($tt==10){
$isbn=$row['Attribute4'];
$isbnLENGTN=strlen($isbn); // should be 10 or 13 long
}


$Name=$row['ProductName'];
$Name = mysql_real_escape_string($Name);

$mid=$row['AdvertiserID'];
$pn = mysql_real_escape_string($mid);
$resultp1 = mysql_query("SELECT * FROM Stores WHERE MID='$pn'");
$row1 = mysql_fetch_array($resultp1);

$source=$row1['P_Id'];

if($source==""){
$source=$pn;
}

$upcLENGTH=strlen($UPC); // should be 12 long


if($UPC!=""&&$UPC!="0"&&$UPC!="NONE"&&$UPC!="none"&&$upcLENGTH=="12"){
$id="upc-".$UPC;
}
elseif($isbn!=""&&$isbn!="0"&&$isbn!="NONE"&&$isbn!="none"&&($isbnLENGTN=="10"||$isbnLENGTN=="13")){
$id="isbn-".$isbn;
}
else{
$id="ML-".$row1['P_Id']."-".$Name;
}
 
$Description=$row['DescriptionLong'];
if($Description==""){
$Description=$row['DescriptionShort'];
}

$Brand=$row['Brand'];
$Image=$row['ProductImageURL'];
$NewUsed='New';
$Instock=$row['Availability'];

$a1=$row['Attribute1'];
$a2=$row['Attribute2'];
$a3=$row['Attribute3'];
$a4=$row['Attribute4'];
$a5=$row['Attribute5'];
$a6=$row['Attribute6'];
$a7=$row['Attribute7'];	
$a8=$row['Attribute8'];
$a9=$row['Attribute9'];
$a10=$row['ClassID'];	
$t1=$row['PrimaryCategory'];
$t2=$row['SecondaryCategory'];

$Description = mysql_real_escape_string($Description);
$a1 = mysql_real_escape_string($a1);
$a2 = mysql_real_escape_string($a2);
$a3 = mysql_real_escape_string($a3);
$a4 = mysql_real_escape_string($a4);
$a5 = mysql_real_escape_string($a5);
$a6 = mysql_real_escape_string($a6);
$a7 = mysql_real_escape_string($a7);

$InStock = mysql_real_escape_string($InStock);


$t1 = mysql_real_escape_string($t1);
$t2 = mysql_real_escape_string($t2);


$network="LS";
if ($Instock!="no"){
$Description = mysql_real_escape_string($Description);
$Brand = mysql_real_escape_string($Brand);
$Image = mysql_real_escape_string($Image);
$NewUsed = mysql_real_escape_string($NewUsed);
$manid = mysql_real_escape_string($manid);


mysql_query("INSERT INTO products (id, name, description, brand, image, NewUsed, tier1, tier2, source, a1, a2, a3, a4, a5, a6, a7, network) VALUES ('$id', '$Name', '$Description', '$Brand', '$Image', '$NewUsed', '$t1', '$t2', '$source', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$network')")or die(mysql_error());
}
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros