Jragon Posted August 4, 2010 Share Posted August 4, 2010 Hey, I'm getting an error: Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\test.php on line 11 My code: <?php $file = fopen ('C:\xampp\htdocs\GDict.txt', 'r'); $i = 0; while(!feof ($file)) { $load[$i] = fgets($file, 1024); mysql_connect("localhost","root",""); mysql_select_db("md5"); $word = $load[$i]; $md5 = md5($word); mysql_query("INSERT INTO md5 VALUES ('$md5', '$word');"); $i++; $limit = count($load); $width2 = $limit; } fclose($file); echo '[o] Loaded' . $limit . 'word. <br />'; echo '<br />Done.'; ?> I have tried changing the php.ini file. max_execution_time = 60 To max_execution_time = 30000000000000 But that still dosent work. Any help would be loved Thanks Jragon Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/ Share on other sites More sharing options...
gwolgamott Posted August 4, 2010 Share Posted August 4, 2010 You could try to set it in the code. http://php.net/manual/en/function.set-time-limit.php Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095179 Share on other sites More sharing options...
kenrbnsn Posted August 4, 2010 Share Posted August 4, 2010 Your code is written poorly. Move these lines <?php mysql_connect("localhost","root",""); mysql_select_db("md5"); ?> outside the loop. Why are you using the array $load? It serves no purpose. What is in the file? And how many records? If you have one item per record, here's how I would do this: <?php mysql_connect("localhost","root",""); mysql_select_db("md5"); $load = file('C:\xampp\htdocs\GDict.txt'); foreach ($load as $word) { $word = trim($word); $q = "INSERT INTO md5 VALUES ('" . md5($word) . "', '$word')"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); } echo '[o] Loaded' . count($load) . 'words. <br />'; echo '<br />Done.'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095183 Share on other sites More sharing options...
Jragon Posted August 4, 2010 Author Share Posted August 4, 2010 With the new one i get the error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in C:\xampp\htdocs\md5\mkdbw.php on line 4 But with the old one i manage to get 29,000 results If you want to download all my word lists go here: http://www.mediafire.com/?3i0y2e85o2thuk9 Thanks Jragon Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095189 Share on other sites More sharing options...
kenrbnsn Posted August 4, 2010 Share Posted August 4, 2010 How big is your file? It sounds like it's very large. If it is, change my code like this: <?php mysql_connect("localhost","root",""); mysql_select_db("md5"); $file = fopen ('C:\xampp\htdocs\GDict.txt', 'r'); $i = 0; while (!feof ($file)) { $word = trim(fgets($file, 1024)); $q = "INSERT INTO md5 VALUES ('" . md5($word) . "', '$word')"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); $i++; } fclose($file); echo '[o] Loaded' . $i . 'words. <br />'; echo '<br />Done.'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095191 Share on other sites More sharing options...
Jragon Posted August 4, 2010 Author Share Posted August 4, 2010 MySQL sintax error: Problem with the query: INSERT INTO md5 VALUES ('3590cb8af0bbb9e78c343b52b93773c9', ''') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''')' at line 1 I cant see anything worng with it. Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095197 Share on other sites More sharing options...
kenrbnsn Posted August 4, 2010 Share Posted August 4, 2010 If this is the message: INSERT INTO md5 VALUES ('3590cb8af0bbb9e78c343b52b93773c9', ''') The second value is a single quote. Are there any works in your file that have single quotes in them? Or are single quotes? Try replacing this line <?php $q = "INSERT INTO md5 VALUES ('" . md5($word) . "', '$word')"; ?> with <?php $q = "INSERT INTO md5 VALUES ('" . md5($word) . "', '" . mysql_real_escape_string($word) . "')"; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095232 Share on other sites More sharing options...
Jragon Posted August 4, 2010 Author Share Posted August 4, 2010 Its now working =] but still the same error: Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\md5\mkdbw.php on line 7 Is there anyway to stop this? Thanks Rory Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095255 Share on other sites More sharing options...
kenrbnsn Posted August 5, 2010 Share Posted August 5, 2010 Use the function set_time_limit to set a longer maximum execution time. Ken Quote Link to comment https://forums.phpfreaks.com/topic/209793-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#findComment-1095379 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.