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("[email protected]","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"; ?> 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 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("[email protected]","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 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 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", 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 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")){ 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 ... ) 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" //.. 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. 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
Archived
This topic is now archived and is closed to further replies.