jeff5656 Posted April 18, 2008 Share Posted April 18, 2008 The following script converts the "rcf_date" field (varchar) to "rcf_date2" (date format) in the table "active_consults". On my test server it works. When I put I applied it to the actual database (930 records) I get: Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\consults\convertdate-3.php on line 9 Here is code that produces that error: Any ideas? <?php include "connectdb.php"; $query = mysql_query("SELECT * FROM active_consults")or die(mysql_error()); while($info = mysql_fetch_array( $query )) { $newdate = date("Y-m-d", strtotime($info['rcf_date'])); $upq = "update active_consults set rcf_date2 = '$newdate' where id_incr = '" . $info['id_incr'] . "'"; $rs = mysql_query($upq) or die("Problem with the update query: $upq<br>" . mysql_error()); } ?> Link to comment https://forums.phpfreaks.com/topic/101690-fatal-error/ Share on other sites More sharing options...
kenrbnsn Posted April 18, 2008 Share Posted April 18, 2008 Take a look at the set_time_limit() function. Ken Link to comment https://forums.phpfreaks.com/topic/101690-fatal-error/#findComment-520262 Share on other sites More sharing options...
shreej21 Posted April 18, 2008 Share Posted April 18, 2008 Just change the time in php.ini file and change the seconds for set_time_limit Link to comment https://forums.phpfreaks.com/topic/101690-fatal-error/#findComment-520268 Share on other sites More sharing options...
jeff5656 Posted April 18, 2008 Author Share Posted April 18, 2008 Oh ok. Well, in the meantime I solved problem by adding LIMIT 0,300 and then run it and then change it to LIMIT 301,500 etc until the file was converted. Link to comment https://forums.phpfreaks.com/topic/101690-fatal-error/#findComment-520316 Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2008 Share Posted April 18, 2008 Running two queries (SELECT and UPDATE) and two slow php functions (date() and strtotime()) for every row is bound to take a long time. Since this is a one time operation, running a single query that updates all the rows at one time in your database administration tool (phpmyadmin or mysql administrator...) would have been the simplest solution. Link to comment https://forums.phpfreaks.com/topic/101690-fatal-error/#findComment-520350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.