...

View Full Version : Need help, with php complete newbie



quartzy
05-06-2009, 12:18 AM
I have configured a contact form for a website, and on checking the form I receive this error.

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tenemb33/public_html/contact_process.php on line 65

the line it refers to is this in the code snippet below.

$name = $_POST["name"];

is this easy to fix? if so how would I fix it? I can post more of the code if needed.



if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(%0a|%0d|\\n+|\\r+)/i", $str);
if ($forbidden)
{
echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
The text you entered is forbidden, it includes one or more of the following:
<br><textarea rows=9 cols=25>";
foreach ($patterns as $key => $value) echo $value."\n";
echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
</b><br><br><br> exit();
}
}
foreach ($_REQUEST as $value) is_forbidden($value);

$name = $_POST["name"];
$email = $_POST["email"];
$thesubject = $_POST["thesubject"];
$themessage = $_POST["themessage"];

$success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
<p align="center"><strong>Your message has been successfully sent to us<br>
</strong> and we will reply as soon as possible.</p>
<p align="center">A copy of your query has been sent to you.</p>
<p align="center">Thank you for contacting us.</p>';

$replymessage = "Hi $name

nobackseat88
05-06-2009, 12:28 AM
Remove the "'s


$name = $_POST["name"];

Should be


$name = $_POST[name];

quartzy
05-06-2009, 12:31 AM
OK thanks I will try that. Do I need to remove all the "" from all the fields below?

$name = $_POST["name"];
$email = $_POST["email"];
$thesubject = $_POST["thesubject"];
$themessage = $_POST["themessage"];

Well I will try both ways. Thanks again.

nobackseat88
05-06-2009, 12:33 AM
Actually,


$name = $_POST["name"];

is usually ok.

It's mostly when you have like:


echo "$_POST["mydata"]";

But I don't see that you are mixing up any double quotes, so that's the only problem I can think of.

Try it real quick, and keep me posted here.

quartzy
05-06-2009, 12:37 AM
Done that, and now I am getting a new error on line 70.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/tenemb33/public_html/contact_process.php on line 70

$name = $_POST[name];
$email = $_POST[email];
$thesubject = $_POST[thesubject];
$themessage = $_POST[themessage];


Line 70
$success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
<p align="center"><strong>Your message has been successfully sent to us<br>
</strong> and we will reply as soon as possible.</p>
<p align="center">A copy of your query has been sent to you.</p>
<p align="center">Thank you for contacting us.</p>';

nobackseat88
05-06-2009, 12:39 AM
I'm re-doing all the quotes on that part...


$success_sent_msg="<p align=\"center\"><strong>&nbsp;</strong></p>
<p align=\"center\"><strong>Your message has been successfully sent to us<br>
</strong> and we will reply as soon as possible.</p>
<p align=\"center\">A copy of your query has been sent to you.</p>
<p align=\"center\">Thank you for contacting us.</p>";


Try that...

That's the way of coding I'm used to, so I know it'll work.

Fou-Lu
05-06-2009, 12:39 AM
Remove the "'s


$name = $_POST["name"];

Should be


$name = $_POST[name];

Disregard this, this information is not correct.

You have an open string right here:


echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
</b><br><br><br> exit();

Close it before the exit call, otherwise it considers upto and including the $_POST[" before the name as a part of the string.


Holy, a lot of posts snuck in there.
As well, you have a close brace with no matching open in this block right below the foreach on you're request. You probably shouldn't use request, choose a post or get since before PHP6 you can't remove the cookie from it without manual work.

nobackseat88
05-06-2009, 12:41 AM
Wow, good eye, Fou-Lou.

PHP is never accurate with the line numbering.

Sometimes the quotes are a problem though, at least in my experience (probably measly compared to yours. :P)

It was the only thing I thought could potentially be the problem.

Sorry for any inconvenience or trouble I caused you. :P

quartzy
05-06-2009, 12:42 AM
Is this what you mean by closing?

echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
</b><br><br><br>" exit();

nobackseat88
05-06-2009, 12:43 AM
echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
</b><br><br><br>";
exit();

quartzy
05-06-2009, 12:44 AM
right I will change it to that, thanks.
Maybe I should make the quotes come back too which I had removed.

Fou-Lu
05-06-2009, 12:45 AM
Wow, good eye, Fou-Lou.

PHP is never accurate with the line numbering.

Sometimes the quotes are a problem though, at least in my experience (probably measly compared to yours. :P)

It was the only thing I thought could potentially be the problem.

Sorry for any inconvenience or trouble I caused you. :P

Thats ok.
Line numbers are actually always correct, the problem is the root cause. In this case, its from an open string further up, but the interpreter cannot see it until it has reached the line in question (65 in this situation). The error itself is on line 60.

nobackseat88
05-06-2009, 12:46 AM
Maybe I should make the quotes come back too which I had removed.

Yep, they were not the problem. :D

quartzy
05-06-2009, 12:51 AM
thanks guys, reckon it works good now, well I got an thankyou from the form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum