*sigh*PHP trouble

He has: 1,380 posts

Joined: Feb 2002

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's picture

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

Laughing out loud

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

and $errors++;, no?

He has: 1,380 posts

Joined: Feb 2002

ahhh thanks

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's picture

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

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.