I currently have around 34k pins/auths generated in my database, and when I run this it just says This webpage is not available
and says that apache crashed. I'm not sure what's causing it to crash because it generated 34k so far without problems. If I could get pointers or anything on what's causing my script to crash that would be great. Thanks. Also I'm running this on a local wamp server. So it gave me an apache crash popup, but I can't seem to get it to show again.
EDIT Here's the crash pop up info:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_7bb4b47e7db260ba266dfdf76b7ba24f8a5e099_cab_175bb644\WERB55A.tmp.appcompat.txt
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_7bb4b47e7db260ba266dfdf76b7ba24f8a5e099_cab_175bb644\WERB56A.tmp.WERInternalMetadata.xml
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_7bb4b47e7db260ba266dfdf76b7ba24f8a5e099_cab_175bb644\WERB5E9.tmp.mdmp
error log:
[Sat Apr 12 19:17:01.362346 2014] [core:notice] [pid 3124:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sat Apr 12 19:17:01.363346 2014] [mpm_winnt:notice] [pid 3124:tid 412] AH00418: Parent: Created child process 940
[Sat Apr 12 19:17:01.599360 2014] [mpm_winnt:notice] [pid 940:tid 308] AH00354: Child: Starting 150 worker threads.
[Sat Apr 12 19:17:04.302514 2014] [mpm_winnt:notice] [pid 3124:tid 412] AH00428: Parent: child process 940 exited with status 255 -- Restarting.
[Sat Apr 12 19:17:04.389519 2014] [mpm_winnt:notice] [pid 3124:tid 412] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sat Apr 12 19:17:04.389519 2014] [mpm_winnt:notice] [pid 3124:tid 412] AH00456: Server built: Feb 22 2013 22:08:37
[Sat Apr 12 19:17:04.389519 2014] [core:notice] [pid 3124:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sat Apr 12 19:17:04.391519 2014] [mpm_winnt:notice] [pid 3124:tid 412] AH00418: Parent: Created child process 2996
[Sat Apr 12 19:17:04.647534 2014] [mpm_winnt:notice] [pid 2996:tid 308] AH00354: Child: Starting 150 worker threads.
code:
<?php
ini_set('xdebug.max_nesting_level', 1000000); //this is to fix the recursion?
ini_set('max_execution_time', 3000000); //300 seconds = 5 minutes
ini_set('memory_limit', -1);
ini_set('error_reporting', E_ALL);
//Enter your database connection details here.
$host = 'localhost';
$db_name = 'pins';
$db_username = 'root';
$db_password = '';
date_default_timezone_set('America/Los_Angeles');
try
{
$pdo = new PDO('mysql:host='. $host .';dbname='.$db_name, $db_username, $db_password);
}
catch (PDOException $e)
{
exit('Error Connecting To DataBase');
}
$starttime = microtime(true);
class lists
{
public $pdo;
function __construct($pdo)
{
$this->pdo = $pdo;
}
function duplicateCode($code)
{
$query = $this->pdo->prepare("SELECT 1 FROM pins WHERE pins_pin = ?");
$query->bindValue(1, $code);
$query->execute();
return $query->fetch();
}
function generateCode()
{
$code = "AA" . substr(str_shuffle('0123456789'), 0, 8);
if($this->duplicateCode($code))
{
return $this->generateCode();
}
else
{
return $code;
}
}
function generatePin($code)
{
$query = $this->pdo->prepare("INSERT INTO pins (pins_pin) VALUES (?)");
$query->bindValue(1, $code);
$query->execute();
return;
}
}
function post_to_url($url, $data) {
$fields = '';
foreach ($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($post);
curl_close($post);
return $result;
}
$list = new lists($pdo);
for($i = 0; $i < 100000; $i++)
{
$code = $list->generateCode();
$pin = $list->generatePin($code);
}
$endtime = microtime(true);
$duration = $endtime - $starttime; //calculates total time taken
echo $duration;
?>