Page 1 of 1

Maximum execution time problem

Posted: Tue Sep 30, 2008 1:50 am
by m2babaey
Hi
I have a table with 3 fields: id, product_id and subcategort_id
I have repeated data in that table. I wrote the code below to delete the repeated data
but I got this error:

Fatal error: Maximum execution time of 60 seconds exceeded in G:\programs\xamp\xampp\htdocs\carat\test.php on line 9
could you please have a look at the code and suggest how I can avoid this error and do what I need?
this is the code:

Code: Select all

 
<?php
include 'connect.php';
 
$wasbefore=mysql_query("SELECT * FROM prod_subcat ")or die(mysql_error());
$wasbeforenum=mysql_num_rows($wasbefore);
echo $wasbeforenum;
$id=0;
while($wasbeforenum-$id){
$wasbefore=mysql_query("SELECT * FROM prod_subcat WHERE id='$id' ")or die(mysql_error());
$row=mysql_fetch_array($wasbefore);
$prod=$row['productID'];
$sub=$row['subcategoryID'];
$wasbefore=mysql_query("SELECT * FROM prod_subcat WHERE subcategoryID='$sub' AND productID='$prod' ")or die(mysql_error());
$wasbeforenum=mysql_num_rows($wasbefore);
if($wasbeforenum>1){
mysql_query("DELETE FROM `prod_subcat` WHERE `id`='$id' ") or die(mysql_error());
}
$id++;
}
 
?>
 

Re: Maximum execution time problem

Posted: Tue Sep 30, 2008 1:56 am
by The_Anomaly
I'm no expert in loops, and have never touched the mysql_* functions (I'm a PDO fanatic), but if all you're doing is a simple database query, you probably have an infinite loop going on there or something.

However, if you're asking how to increase your maximum execution time, you can easily do that in your php.ini.

Re: Maximum execution time problem

Posted: Tue Sep 30, 2008 10:14 am
by m2babaey
solved!
i used the same variable in while loop and while statement.