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: <?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++; } ?> PHP:
That may not work, if the server does not allow this onscript modification. You can edit the active php.ini (for xampp it is located in xampp/apache/bin directory) On the line below max_execution_time = 60 ; Maximum execution time of each script, in seconds Code (markup): change the value of 60 to 120 or whatever you need. Then restart the apache server and try.
Hi, edit your while loop and make sure its correct. Your while loop is incorrect and it cause an infinite execution time.
after your first include, put this ini_set('max_execution_time',''); .... and when before ?> put, ini_restore('max_execution_time');