*sigh*PHP trouble
hi...i finally got around to getting PHP support (thanks SarviHosting!) but i keep getting an error that says i need ' " or ; at line 10 of this script
<?php
function validate_form()
{
global $Name, $Email;
$errors=0;
if (!trim($Name))
{
echo "<br><font color="#FF0000"><b>Name</b> is required.";
$errors++;
}
if (!trim($Email))
{
echo "<br><font color="#FF0000"><b>Email</b> is required.";
$errors++
}
switch ($errors)
{
case 0:
return TRUE;
case 1:
echo "<br><br>Please go back and fill in the required fields.";
return FALSE;
default:
echo "<br><br>Please go back and fill in the required fields.";
return FALSE;
}
}
function update_database()
{
echo "<br>Thank you for subscribing.";
$ok = validate_form()
$fp = fopen ("/home/westernc/public_html/email/names.txt", "w");
fwrite($fp, "Name: $Name\n");
fwrite($fp, "Email: $Email\n");
fclose ($fp);
}
if ($ok)
update_database();
?>
anybody see it? i dont...thanks
nike_guy_man posted this at 00:26 — 8th April 2003.
They have: 840 posts
Joined: Sep 2000
Yes -- Double quotes must be escaped
<?php
{
echo \"<br><font color=\\"#FF0000\\"><b>Name</b> is required.\";
$errors++;
}
if (!trim($Email))
{
echo \"<br><font color=\\"#FF0000\\"><b>Email</b> is required.\";
$errors++
}
?>
Suzanne posted this at 01:11 — 8th April 2003.
She has: 5,507 posts
Joined: Feb 2000
and $errors++;, no?
kb posted this at 01:14 — 8th April 2003.
He has: 1,380 posts
Joined: Feb 2002
ahhh thanks
kb posted this at 01:26 — 8th April 2003.
He has: 1,380 posts
Joined: Feb 2002
amazing..now i'm getting an error at line 38...checked for double quotes this time...as well as semi-colons...what now....if you see this or ANY other mistakes, help me out please
(anybody know of any online PHP validators? this would help mucho)
nike_guy_man posted this at 01:42 — 8th April 2003.
They have: 840 posts
Joined: Sep 2000
$ok = validate_form();
semis at the end of each line
Check into the Zend Development Environment as far as a validator
kb posted this at 01:50 — 8th April 2003.
He has: 1,380 posts
Joined: Feb 2002
thanks
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.