mfleming Posted October 24, 2010 Share Posted October 24, 2010 Hi. I tried to add some more if statements to check for validation and I'm now getting this error. The "on line ###" changes depending how many fields are FALSE. Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 35 bytes) in /home/content/f/u/s/fusionfashion/html/registration.php on line 133 I think it has to do with the php.ini file. So I added the memory_limit in the php.ini file. register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 memory_limit = 128M post_max_size = 128M SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" [Zend] zend_extension=/usr/local/zo/ZendExtensionManager.so zend_extension=/usr/local/zo/4_3/ZendOptimizer.so But I'm still getting the error. How to I check my php version and this value within a browser? <?php phpinfo() ?> Found this. Its showing 64M in LOCAL and MASTER. But I just updated the local? Link to comment https://forums.phpfreaks.com/topic/216685-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/ Share on other sites More sharing options...
Pikachu2000 Posted October 24, 2010 Share Posted October 24, 2010 If you're exhausting the memory in a validation routine, there's probably something wrong with the code, not the server settings. Link to comment https://forums.phpfreaks.com/topic/216685-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/#findComment-1125793 Share on other sites More sharing options...
mfleming Posted October 24, 2010 Author Share Posted October 24, 2010 What is wrong with my code? (The memory errors started happening when I added more IF statements inside the WHILE loop) My Code: <? phpinfo(); ?> <?php session_start(); ?> <?php $submit = $_POST['submit']; // Form Data $firstname = strip_tags($_POST['firstname']); $lastname = strip_tags($_POST['lastname']); $address = strip_tags($_POST['address']); $email = strip_tags($_POST['email']); $repeatemail = strip_tags($_POST['repeatemail']); $phone = strip_tags($_POST['phone']); $salonname = strip_tags($_POST['salonname']); $salonaddress = strip_tags($_POST['salonaddress']); $salonprov = strip_tags($_POST['salonprov']); $salonpostal = strip_tags($_POST['salonpostal']); $salonconfirm = strip_tags($_POST['salonconfirm']); $enewsletter = strip_tags($_POST['enewsletter']); $saloncountry = strip_tags($_POST['saloncountry']); $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $username = strip_tags($_POST['username']); $date = date("Y-m-d"); // Set e-mail recipient $myemail = "[email protected]"; $errormsg['MissAll'] = "Please Enter in ALL Fields!"; $errormsg['ErrFirstName'] = "Please Enter Valid First Name"; $errormsg['ErrLastName'] = "Please Enter Valid Last Name"; $errormsg['ErrAdd'] = "Please Enter Valid Address"; $errormsg['ErrEmail'] = "Please Enter Valid Email"; $errormsg['ErrEmailMatch'] = "Your Email address do not match!"; $errormsg['ErrPhone'] = "Please Enter Valid Phone Number"; $errormsg['ErrPassLngt'] = "Password must be between 6 and 32 characters"; $errormsg['ErrPassMatch'] = "Password do not match!"; $errormsg['ErrSalNam'] = "Please Enter Valid Salon Name"; $errormsg['ErrSalAdd'] = "Please Enter Valid Salon Address"; $errormsg['ErrProv'] = "Please Select Province/State"; $errormsg['ErrPstl'] = "Please Enter Valid Postal/Zip Code"; $errormsg['ErrCntry'] = "Please Select Country"; $errormsg['ErrSalPro'] = "Please Confirm Salon Professional"; $errormsg['ErrSecCode'] = "Please Enter Security Code"; $errormsg['ErrEmailUsed'] = "Email Address already being used. Please us an alternate Email"; $errormsg['PlaceHold'] = ""; $errortrack[] = $errormsg['PlaceHold']; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_POST[submit]){ if ($errorstop = "go") { // loop through if statements until forms completed $errorstop="go"; while ($errorstop<>"stop") { if ($_SESSION[key]==$_POST[user_code]){ $_SESSION[key]=''; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrSecCode']; $errorcount=$errorcount+1; $errorstop="stop"; } if (strlen($firstname)>1||strlen($firstname)<26) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrFirstName']; $errorcount=$errorcount+1; $errorstop="stop"; } if (strlen($lastname)>1||strlen($lastname)<26) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrLastName']; $errorcount=$errorcount+1; $errorstop="stop"; } if (strlen($address)>1||strlen($address)<26) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrAdd']; $errorcount=$errorcount+1; $errorstop="stop"; } // Call it with the code below $email = trim($_POST['email']); if(!checkEmail($email)) { // echo 'Invalid email address!'; $errortrack[] = $errormsg['ErrEmail']; $errorstop="stop"; } else { // echo "Email is Valid"; $errorstop="stop"; //Get out of while loop } // checks email input match if ($email<>$repeatemail) { // echo "<p>Emails do not match!</p>"; $errortrack[] = $errormsg['ErrEmailMatch']; $errorstop="stop"; } else { $errorstop="go"; } // check phone input match if ($phone) { $errortrack[] = $errormsg['ErrPhone']; $errorstop="stop"; } else { $errorstop="go"; } //check password length if (strlen($password)>32||strlen($password)<6) { // echo '<p class="formecho">Password must be between 6 and 32 characters</p>'; $errortrack[] = $errormsg['ErrPassLngt']; $errorstop="stop"; } else { $errorstop="go"; } //end of password length check // check password input match if ($password<>$repeatpassword) { // echo "<p>Passwords do not match!</p>"; $errortrack[] = $errormsg['ErrPassMatch']; $errorstop="stop"; } else { $errorstop="go"; // checks email input match } if (strlen($salonname)>1||strlen($salonname)<26) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrSalNam']; $errorcount=$errorcount+1; $errorstop="stop"; } if (strlen($salonaddress)>1||strlen($salonaddress)<26) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrSalAdd']; $errorcount=$errorcount+1; $errorstop="stop"; } // Checks Proper input of Province/State if ($salonprov=="Please Select" || $salonprov=="------------") { // echo '<p class="formecho">Please Select a Valid Province/State!</p>'; $errortrack[] = $errormsg['ErrProv']; $errorstop="stop"; } else { $errorstop="go"; } if ($salonpostal) { $errorstop="go"; //echo "TRUE"; } else { //echo "False - Stop 0"; $errortrack[] = $errormsg['ErrPstl']; $errorcount=$errorcount+1; $errorstop="stop"; } // Checks Proper input of Country if ($saloncountry=="Please Select") { // echo '<p class="formecho">Please Select a Valid Country!</p>'; $errortrack[] = $errormsg['ErrCntry']; $errorstop="stop"; } else { $errorstop="go"; }// End checks Country input // Checks Proper input Salon Confirmation if (isset($_POST['$salonconfirm'])=="1") { // echo '<p class="formecho">Please Confirm You are your Salon</p>'; $errortrack[] = $errormsg['ErrSalPro']; $errorstop="stop"; } else { $errorstop="go"; } // End checks Salon Confirm input }//End While Loop $errorstop="go"; include "dbConfig.php"; // table is mysql table, WHERE FIELD_NAME ='text'" OR =>='10'"; or VAR = '.$variable.') // SQL grabs records // * means "ALL RECORDS" or use FIELD_NAME, FIELD_NAME2 instead of * // $usertable = user where user is the TABLE // use WHERE FIELD_NAME = '$email' variable $SQL = "SELECT email FROM {$usertable} WHERE email = '{$email}' "; // mysql_query() is used to send a SQL query to database and returns TRUE or FALSE, or FILE HANDLE if using SELECT // $result = mysql_query($SQL); only POINTS to results $result = mysql_query($SQL); // mysql_fetch_assoc($result) GETS RESULTS from $result // assoc or associative array brings keys as text Array['One'] =, Array['Two']= and NOT Array[1]= // Place results into $db_field Array $db_field = mysql_fetch_assoc($result); if ($result) { $db_field = mysql_fetch_assoc($result); //echo $db_field['email'] .' '.'has already been used!'; $errortrack[] = $errormsg['ErrEmailUsed']; $errorstop="stop"; } else { $errorstop="go"; // Thank you Page $insertGoTo = "thankyou.php"; header(sprintf("Location: %s", $insertGoTo)); // encrypt password $temppass = $password; $password = md5($password); $repeatpassword = md5($repeatpassword); // dBase file include "dbConfig.php"; //open database //generate random number for activation process $random = md5(rand(23456789,987654321)); // register the user! // Set default username $username = $email; // INSERT INTO user... replace user with table name // make sure you have the same number and order of values as the database has $queryreg = mysql_query(" INSERT INTO user VALUES ('','$firstname','$lastname','$username','$password','$date','$email','$phone','$address','$salonname','$salonaddress','$salonprov','$salonpostal','$saloncountry','$salonconfirm','$enewsletter','$random','0')"); //Insert ID based on last ID in database $lastid = mysql_insert_id(); //send activation email $to = $email; //Change to $myemail to send activation to webmaster $subject = "Activate Salon Member Acctount at Fusion Fashion Hair"; $headers = "From: [email protected]"; $server = "mail.fusionfashionhair.com"; //change php.ini and set SMTP to $server ini_set("SMTP",$server); $body = " $firstname $lastname from $salonname is wanting a membership, \n\n Please click on the link provided below to activate the account with Fusion Fashion Hair http://www.fusionfashionhair.com/activate.php?id=$lastid&code=$random \n\n Username = $username \n Thank you, Customer Service "; //function to send email mail($to, $subject, $body, $headers); } //End if Result // End check for existance } else { // echo '<p class="formecho">Please fill in <b>ALL</b> fields!</p>'; $errortrack[] = $errormsg['MissAll']; $errorstop="stop"; } //End if GO check }// End if Sumbit ?> <?php // LINUX PLATFORM OPTION 3 // checkEmail function checks standard email format same as preg_match() // checkEmail function checks DSN records using checkdnsrr Use list() to seperate name and domain using split function // checkdnsrr ONLY WORKS on LINUX PLATFORM // Check to see if domain and username is active // uses fsockopen() to check if its in use using port 25 function checkEmail($email) { // checks proper syntax if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS if(!checkdnsrr($domain, 'MX')) { return false; } return true; } return false; } ?> <?php function checkStringText($str) { // checks proper syntax //if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $firstname)) { //Removes white space, null, tabs, new lines from both sides trim($str); // Strips HTML Tags strip_tags($str); if(preg_match('^[0-9]+:/[\s|\n|\t|*|@|&|/',$str)) { echo "special char found!"; } } ?> Link to comment https://forums.phpfreaks.com/topic/216685-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/#findComment-1125794 Share on other sites More sharing options...
mfleming Posted October 25, 2010 Author Share Posted October 25, 2010 I found the error. My while loop was set to stop if $errorstop="stop" which is fine.... but I kept resetting the $errorstop="go" which causes an infinite loop which caused the out of memory error as it would have gone on forever.. Whoops Thanks Link to comment https://forums.phpfreaks.com/topic/216685-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/#findComment-1126030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.