simcoweb Posted February 6, 2010 Share Posted February 6, 2010 Hi, need another set of eyes. Getting error: Parse error: syntax error, unexpected T_STRING in /home2/wwwpawz/public_html/ajax.php on line 14 For this code: <? $name = stripslashes($_POST['Name']); $email = stripslashes($_POST['Email']); $phone = stripslashes($_POST['Phone']); $address = stripslashes($_POST['Address']); $city = stripslashes($_POST['City']); $number = stripslashes($_POST['Number']); $pettypes = stripslashes($_POST['PetTypes']); $petnames = stripslashes($_POST['PetNames']); $departuredate = stripslashes($_POST['DepartureDate']); $returndate = stripslashes($_POST['ReturnDate']); $specialinstructions = stripslashes($_POST['SpecialInstructions']); if(mail("bsniff@gmail.com","Little Pawz Inquiry"," ."Name: ".$name."\n" ."Email: ".$email."\n" ."Phone: ".$phone."\n" ."Address: ".$address."\n" ."City: ".$city."\n" ."Number of Pets: ".$number."\n" ."Pet Types: ".$pettypes."\n" ."Pet Names: ".$petnames."\n" ."Departure Date: ".$departuredate."\n" ."Return Date: ".$returndate."\n" ."Special Instructions: ".$specialinstructions."\n"; (From $name, $email, $phone)","From: $email")){ echo "$name $email $phone $specialinstructions"; } echo "<h3>Your Email Order Was Successfully Sent!</h3><br /> <i>Here is the information you submitted. Please review and resend if any items are incorrect.</i> <br /><br/> <b>Name:</b> $name<br /><b>Email:</b> $email<br /><b>Phone:</b> $phone<br /><b>Address:</b> $besttime<br/><b>City:</b> $city<br/> <b>Number of Pets:</b> $number<br/><b>Pet Types:</b> $pettypes<br/><b>Pet Names:</b> $petnames<br/><b>Departure Day:</b> $departuredate<br/><b>Return Day:</b> $returndate<br/>$shipping2<br/><b>Special Instructions:</b> $specialinstructions"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/ Share on other sites More sharing options...
MatthewJ Posted February 6, 2010 Share Posted February 6, 2010 When I copy and paste it into an editor with code highlighting the strings are all messed up... all of your name: etc. portions are outside of the quotes. I would move the mail() outside of the if instead of chaining them together... might make it easier to see Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007688 Share on other sites More sharing options...
thewooleymammoth Posted February 6, 2010 Share Posted February 6, 2010 <?php $name = stripslashes($_POST['Name']); $email = stripslashes($_POST['Email']); $phone = stripslashes($_POST['Phone']); $address = stripslashes($_POST['Address']); $city = stripslashes($_POST['City']); $number = stripslashes($_POST['Number']); $pettypes = stripslashes($_POST['PetTypes']); $petnames = stripslashes($_POST['PetNames']); $departuredate = stripslashes($_POST['DepartureDate']); $returndate = stripslashes($_POST['ReturnDate']); $specialinstructions = stripslashes($_POST['SpecialInstructions']); if(mail("bsniff@gmail.com","Little Pawz Inquiry", "Name: ".$name."\n" ."Email: ".$email."\n" ."Phone: ".$phone."\n" ."Address: ".$address."\n" ."City: ".$city."\n" ."Number of Pets: ".$number."\n" ."Pet Types: ".$pettypes."\n" ."Pet Names: ".$petnames."\n" ."Departure Date: ".$departuredate."\n" ."Return Date: ".$returndate."\n" ."Special Instructions: ".$specialinstructions."\n"; (From $name, $email, $phone)","From: $email")){ echo "$name $email $phone $specialinstructions"; } echo "<h3>Your Email Order Was Successfully Sent!</h3><br /> <i>Here is the information you submitted. Please review and resend if any items are incorrect.</i> <br /><br/> <b>Name:</b> $name<br /><b>Email:</b> $email<br /><b>Phone:</b> $phone<br /><b>Address:</b> $besttime<br/><b>City:</b> $city<br/> <b>Number of Pets:</b> $number<br/><b>Pet Types:</b> $pettypes<br/><b>Pet Names:</b> $petnames<br/><b>Departure Day:</b> $departuredate<br/><b>Return Day:</b> $returndate<br/>$shipping2<br/><b>Special Instructions:</b> $specialinstructions"; ?> you owe me cake Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007699 Share on other sites More sharing options...
simcoweb Posted February 6, 2010 Author Share Posted February 6, 2010 thewooleymammoth, that code throws an error on line 24 now. unexpected ';' on line 24 Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007713 Share on other sites More sharing options...
premiso Posted February 6, 2010 Share Posted February 6, 2010 Look at line 24 and see what's a miss, perhaps use a syntax highlighting program to code in? ."Special Instructions: ".$specialinstructions."\n"; Replace the semicolon in that line with a comma. ."Special Instructions: ".$specialinstructions."\n", Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007715 Share on other sites More sharing options...
simcoweb Posted February 6, 2010 Author Share Posted February 6, 2010 That produces an error on line 26 now unexected T_VARIABLE Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007721 Share on other sites More sharing options...
premiso Posted February 6, 2010 Share Posted February 6, 2010 That produces an error on line 26 now unexected T_VARIABLE These are basic errors, I would highly suggest you read up on debugging at the tutorial Debugging a Beginners Guide. As you seem to lack any debugging skills. ."Special Instructions: ".$specialinstructions."\n", ."(From $name, $email, $phone)\n","From: $email")){ Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007724 Share on other sites More sharing options...
simcoweb Posted February 6, 2010 Author Share Posted February 6, 2010 Usually i'm fairly good at debugging but i'll definitely refresh my knowledge on it. This was driving me looney since it seemed to just jump to the next line (the error) on each fix. FYI, your last code snippet also produced an error, unexpected '.' on line 27. Changed yours: ."Special Instructions: ".$specialinstructions."\n", ."(From $name, $email, $phone)\n","From: $email")){ to this: ."Special Instructions: ".$specialinstructions."\n", "(From $name, $email, $phone)","From: $email")){ and the error went away. (removed . in front of the "(From ... ) Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007736 Share on other sites More sharing options...
ignace Posted February 6, 2010 Share Posted February 6, 2010 If you ever face something like: $name = stripslashes($_POST['Name']); $email = stripslashes($_POST['Email']); $phone = stripslashes($_POST['Phone']); $address = stripslashes($_POST['Address']); $city = stripslashes($_POST['City']); $number = stripslashes($_POST['Number']); $pettypes = stripslashes($_POST['PetTypes']); $petnames = stripslashes($_POST['PetNames']); $departuredate = stripslashes($_POST['DepartureDate']); $returndate = stripslashes($_POST['ReturnDate']); $specialinstructions = stripslashes($_POST['SpecialInstructions']); You can transform that to: function clean($value) { return addslashes(htmlentities(stripslashes($value))); } $_POST = array_map('clean', $_POST); extract($_POST); //.. "Name: ".$Name."\n" ."Email: ".$Email."\n" ."Phone: ".$Phone."\n" ."Address: ".$Address."\n" ."City: ".$City."\n" ."Number of Pets: ".$Number."\n" ."Pet Types: ".$PetTypes."\n" ."Pet Names: ".$PetNames."\n" ."Departure Date: ".$DepartureDate."\n" ."Return Date: ".$returndate."\n" ."Special Instructions: ".$SpecialInstructions."\n" //.. Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007830 Share on other sites More sharing options...
PFMaBiSmAd Posted February 6, 2010 Share Posted February 6, 2010 Using extract($_POST); (unless you use EXTR_SKIP or EXTR_PREFIX_ALL as the second parameter) emulates what register_globals did and allows hackers to set any of your program variables to any value they want. Quote Link to comment https://forums.phpfreaks.com/topic/191106-going-nuts-trying-to-spot-simple-error/#findComment-1007906 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.