PHP - Regular Expressions Crashing Page?!
I have a payment form that submits its results to Authorize.net.
It works on my laptop without an SSL certificate using an Authorize.net test account. But when I transfer this one file over to my GoDaddy account - which has cURL enabled and an SSL certificate - the page crashes when you submit the form results. (Actually you just get a blank page except for echo statements I added?!) If I take out my "Form Validation" block - which uses Regular Expressions - then the form runs on the server?! Someone said it might be that "cURL must have SSL enabled in the build", but that isn't the issue, because I can send data to an HTTPS connection and receive a response back?! Here is a streamlined version of my code... Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href=".css"> <style type="text/css" > someStyleHere{ font-weight: bold; } </style> </head> <body> <?php // Check Form. echo '*** Checking for Submitted Form ***<br />'; if (isset($_POST['submitted'])){ // Handle Form. echo '*** Form was Submitted ***<br />'; echo '*** Handling Form ***<br />'; // Trim all incoming data. $trimmed = array_map('trim', $_POST); // CHECK BILLING INFORMATION. echo '*** Check for Form Errors ***<br />'; // Check First Name. if (!empty($_POST['firstName'])){ if (preg_match('/^[A-Z \'.-]{2,20}$/i', $_POST['firstName'])){ $firstName = $_POST['firstName']; }else{ $errors['firstName'] = 'Must be 2-20 characters (A-Z \' . -)'; } }else{ $errors['firstName'] = 'Please enter your First Name.'; } // Determine if any errors. if (empty($errors)){ // PROCESS PAYMENT. echo '*** Processing Form ***<br />'; $post_url = "https://test.authorize.net/gateway/transact.dll"; // Output the Response Array to the screen as an HTML Numbered List. echo "<OL>\n"; foreach($response_array as $value){ echo "<LI>" . $value . " </LI>\n"; } echo "</OL>\n"; // Printe Response Code. switch($response_array[0]){ case "1": echo "Response Code: Approved"; break; case "2": echo "Response Code: Declined"; break; } // Do not re-display Payment Form!!! exit(); // ********************************************************************* }// End of PROCESS PAYMENT. }// End of HANDLE FORM. ?> <!-- HTML PAYMENT FORM --> <form id="payment" action="" method="post"> <fieldset> <legend>Billing Details</legend> <ol> <!-- First Name --> <li> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" class="text" type="text" maxlength="20" value="<?php echo $firstName; ?>" /> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> </li> </ol> </fieldset> <!-- Submit Form --> <fieldset id="submit"> <input name="submit" type="submit" value="Place Order" /> <input name="submitted" type="hidden" value="true" /> </fieldset> </form> </body> </html> With my Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** With NO Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** *** Check for Form Errors *** *** Processing Form *** post-string = x_login= and so on... Response Code: Approved (Which means the code is working...) I am at wit's end with this problem... Thanks, Debbie Similar TutorialsThis topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=341968.0 Okay, I have a problem. I need to display multilple output of a file with a similar file name I.E. file1: 6002010.pdf file2: 6002010.mmddyyyy.pdf Now the first part of the file stays the same, but there is a time stamp on modified versions of the file. But in my output I need to display all the files with the 6002010. Could I use a wildcard such as 6002010* to get all the files to output on the screen? Or do I need to use a regular expression? i need to split words and add to a array from filter input. i can split words with [ ] (Space character). But also i need to not split "word1 word2" with space character. for example: Filter input "word1 word2" word3 word4 my array will need to be like this after split arr[0] = word1 word2 arr[1] = word3 arr[2] = word4 can some one help me about this? By the way im sorry for my poor english Thanx This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=351100.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=315565.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=334128.0 I'm a beginner. I should debug my code from the webserver. When i use arrays and get some error, i generally make "var_dump" or "print_r" to check my data contents. Most of the time, by echo'ing, i can get the errors with related to structure of arrays etc. But when dumped file is too big, webserver crashes. I use shared hosting, so it becomes problem. For example Code: [Select] $html = file_get_html( 'http://www.example.com' ); var_dump($html);I suppose, PHP runs it very long and reserved memory, RAM etc. becomes exhausted. To solve this i sometime write the outputs to txt files. But it would be handy to check the results from browser. What can you recommend me to not to crash server? Thank you I'm using a program called Do It Again which is a mouse recorder. I am trying to launch a shortcut to it from my php script. Seems all is okay when I run it as a stand alone program, and is not set to have to be run by the administrator - still when I launch it from my php page I get the windows popup saying the program has crashed. "DoItAgain.exe has encountered a problem and needs to close. We are sorry for the inconvenience." It's not the program, but something in my code: Code: [Select] $command= 'C:\\xampp\htdocs\poster\dia\\Monty_20.dia'; exec($command); I also tried the following but get the windows popup error: "The Application Failed to Initiate Properly" Code: [Select] $command= ('START C:\\xampp\\htdocs\\poster\\dia\\Monty_20.dia'); Any help would be greatly appreciated. I've been at it for 3 hours now and I'm pulling out what little hair I have left. Hey all, Wondering maybe someone can help me out, I am training to be a firefighter (I am not a coder) and am writing a little script for my local volunteer fire brigade to try help em out a little and I am stuck! It doesn't do much but grab the address out of a pager message but I have searched and tried a few ways to get this and now I am tired and just can't get my head around how to do this! Let me explain, Below are 2 pager alert messages and I have a sore head of a time trying to extract the address and job details of the second message into a php string using Expressions/Regex... Here are 2 example messages: Code: [Select] 0571040 15:45:21 30-04-12 @@ALERT F546356345 THEB8 STRUC1 SMELL OF SMOKE AND ALARM OPERATING 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD //CROSSTREET2 AV M 99 A1 (429085) CTHEB CBOROS PT28 [THEB] 0571040 15:45:21 30-04-12 @@ALERT F546356345 THEB8 STRUC1 SMELL OF SMOKE AND ALARM OPERATING 4 / 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD //CROSSTREET2 AV M 99 A1 (429085) CTHEB CBOROS PT28 [THEB] You will note the second address has 4 / 900 at the start or it could say Unit 4 / 900... and this is where my issue starts! The addresses can come in the 2 different formats, I have first one sorted with the code below but this address with no 4 / 900 some road just has me and my code below stumped. The extra / is just to complex a thing for me and my brain to handle! lol Please Help! As you can see I use the first slash as the first cross street but in the second case above the first / is now a part of the address... Below is what I have so far: Code: [Select] function get_string_between2($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $fullstring = "$rawPage"; if ( strpos($fullstring, ' STRUC1 ')!== false ) { $parsed = get_string_between2($fullstring, "STRUC1", "/"); } $input = "$parsed"; preg_match('/([^0-9]+)(.*)/', $input, $matches); $jobdet = "$matches[1]"; $jobadd = "$matches[2]"; Now this works fine for the top message and I get this as the result: $jobdet = SMELL OF SMOKE AND ALARM OPERATING $jobadd = 900 SOME ROAD SOMESUBURB $firstcrossstreet = /CROSSSTREET1 RD $secondcrossstreet = //CROSSSTREET2 AV For the second message it's all wrong with this the result: $jobdet = SMELL OF SMOKE AND ALARM OPERATING $jobadd = 4 $firstcrossstreet = / 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD $secondcrossstreet = //CROSSSTREET2 AV I know it's the / causing it but how can I make the code handle either case? Any help would be greatly appreciated! Thanks! I am trying to check my youtube code value and see if &rel=0 has been added to it and if not added it. I suck at regular exp can someone help? Code: [Select] <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need to change/replace these into: Code: [Select] <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need a generic regular expression for this? Can anyone provide the generic regular expression for this to replace? Trying=> $abc = str_replace(array($generic-regular-expression),'<pre> or <pre class="brush:cpp"> or <pre class="brush:javascript"> ..... ',$str); Hi people,
i need to find 16x150gr in Dried Pomegranate Arils16x150gr but the format can vary from
Mt Ceder Balsamic Vinegar 12x250ml to
Mt Ceder Balsamic Vinegar 2x2ltr to
Dried Kalamata Olives 4x1kg. i guess you got the drift
i tried something like : '/[1-9]+x[1-9]+[a-z]+/' but i am so useless at regex.
Thank you!
Hey I'm pretty new to regular expression, so I might have made a silly mistake. I want to check if there are any symbols/special characters (not letters or numbers) in a string. I have the code below. function validateKeywords($kw) { if (preg_match("/[^A-Za-z0-9]/", $kw)) { echo 'validation of keywords failed<br />'; return false; // String contains symbols (not letters or numbers) - incorrect format! } else { echo 'validation of keywords succeeded<br />'; return true; // Correct format } } // Testing validateKeywords('some random string I wrote for testing purposes'); // should succeed validateKeywords('some random 10 string I wrote for testing purposes 2010'); // should succeed validateKeywords('some random, string, I wrote for 19 testing purposes'); // should fail validateKeywords('some, random, string I wrote, for testing purposes'); // should fail The problem is that all 4 calls return false and print that the validation failed. So, where did I mess up? Thanks! Can anyone help me. I have very little knowledge about programming and coding and php, but I am tutoring myself on these. I want to write a code that will search for a movie in this website search => http://myandyourface.com/DELETE/imdb-poster.php. NOTE: in searching for the movie, the movie name with more than one word can be type in in combination form by using the + sign. For example, the movie "the vow", typing that into the search box will be so => the+vow. As an example, I got the result as show below: {"Title":"The Vow","Year":"2012","Rated":"PG-13","Released":"10 Feb 2012","Genre":"Drama, Romance","Director":"Michael Sucsy","Writer":"Jason Katims, Abby Kohn","Actors":"Rachel McAdams, Channing Tatum, Sam Neill, Jessica Lange","Plot":"A car accident puts Paige (McAdams) in a coma, and when she wakes up with severe memory loss, her husband Leo (Tatum) works to win her heart again.","Poster":"http://ia.media-imdb.com/images/M/MV5BMjE1OTU5MjU0N15BMl5BanBnXkFtZTcwMzI3OTU5Ng@@._V1_SX320.jpg","Runtime":"N/A","Rating":"N/A","Votes":"N/A","ID":"tt1606389","Response":"True"} So, this is what I wanted to do, I wanted to write a php code expression that will search for a specific movie and provide the result as above,and then using the regex and str_replace, and others, I will be able to remove all the above detail information and have ONLY the image link as in above, which is => http://ia.media-imdb.com/images/M/MV5BMjE1OTU5MjU0N15BMl5BanBnXkFtZTcwMzI3OTU5Ng@@._V1_SX320.jpg I will appreciate any help in creating a code for this Thanks! Hello everyone,
example string
<?php $string = ""; $string .= "<textarea id='convert'> 'AA' </textarea>"; $string .= "<textarea id='convert'> 'BB' </textarea>"; $string .= "<textarea id='not_convert'> 'AA' </textarea>"; $string .= "<textarea id='not_convert'> 'DD' </textarea>"; ?>I want to change 'AA' to 'ZZ' which is inside textarea with the id convert only. How is it possible with the help of regular expression? This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=310676.0 Hi, I've got a form where the user submits a date as a text field (as 12-12-2012 for example) called closing. The form submits fine without my regular expression validation, but whenever I try to validate it, it returns the error message I wrote for if no results turn up. Ive tried: Code: [Select] <?php if (!preg_match ("[0-9]{2}-[0-9]{2}-[0-9]{4}", $_POST["closing"])) { $_SESSION["report"] = "<b>Error:</b> Date is in the wrong format. It must be dd-mm-yyyy<br />"; $_SESSION["reportcount"] = 0; } ?> and Code: [Select] <?php if (!preg_match ("\d{2}-\d{2}-\d{4}", $_POST["closing"])) { $_SESSION["report"] = "<b>Error:</b> Date is in the wrong format. It must be dd-mm-yyyy<br />"; $_SESSION["reportcount"] = 0; } ?> Any ideas? This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=325429.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317585.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=316160.0 |