Forum Moderators: coopster

Message Too Old, No Replies

New to PHP

error message confuses newcomer

         

robert3406

9:33 pm on Jan 19, 2008 (gmt 0)

10+ Year Member


This is my first post on this forum, and I hope you will inform me if I have failed to follow etiquette......if so I apologize. thanks for the help in advance.

I get this error message in both IE and Firefox:
"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/content/r/o/b/robertnking/html/gfi/send_email.php on line 36"

<?php

function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
header("Location: contact.php?status=0");
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{¦}~-][A-Za-z0-9!#$%&'*+/=?^_`{¦}~\.-]
{0,63})¦(\"[^(\\¦\")]{0,62}\"))$", $local_array[$i])) {
header("Location: contact.php?status=0");
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
die ("Invalid email address");// Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])¦([A-Za-z0-9]+))$",
$domain_array[$i])) {
header("Location: contact.php?status=0");
}
}
}
return $email;
}

function escape_val($string) {
$string = str_replace(array('"',"<",">"),
array(""","<",">"), $string);
return $string;
}

$check_email = check_email_address($_REQUEST['email']);
$name = escape_val($_REQUEST['name']);
$message = escape_val($_REQUEST['message']);
$time = date('l dS \of F Y h:i:s A');
$email_subject = "New contact message from ".$site_name."";

if(mail($admin_email,$email_subject,$message,
"From:$check_email,Reply-to:$check_email")) {
header("Location: contact.php?status=1");
exit;
} else {
header("Location: contact.php?status=0");
}
?>

venelin13

9:42 pm on Jan 19, 2008 (gmt 0)

10+ Year Member



You are using the double quotes incorrect:

array(""","<",">"), $string);

the correct should be:

array('"',"<",">"), $string);

robert3406

10:25 pm on Jan 19, 2008 (gmt 0)

10+ Year Member



Thank you so much! I tried for longer than I would like to admit to figure out what was wrong with the that file. Works perfectly. What would you suggest for learning php a little bit better? Is there a website you would suggest? or perhaps a book? "for dummies" or otherwise......thank again

venelin13

10:49 pm on Jan 19, 2008 (gmt 0)

10+ Year Member



I am glad I was able to help you!

Well, there are a lot of resources to learn PHP. For example, at amazon.com you can find a good collection of books for any level. Select a couple of them for your level and read the users reviews.

phranque

2:14 am on Jan 20, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], robert3406!

be sure to check out the Library [webmasterworld.com] and Charter [webmasterworld.com] links for the PHP forum for various references and resources.