Jump to content

Going nuts trying to spot simple error


simcoweb

Recommended Posts

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";
?>

Link to comment
Share on other sites

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
Share on other sites

<?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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.