I was trying to build a new website for myself, and I used an old php form to email section. Funny thing it was working fine on the old one, for some reason it is no longer functioning right: it displays the whole when testing in firefox.

When I uploaded it nontheless, it gave me the error:

Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/sampharo/emirates-enterprise.com/register.php on line 106

This corresponds to the line: $subject = '[Registration] : ' . $subject;

The following is the php part

    <?php
                 $error    = ''; // error message
                 $name     = ''; // sender's name
                 $email    = ''; // sender's email address
                 $course   = ''; // chosen course
                 $subject  = 'Course Registration Form'; // subject
                 $message  = ''; // the message itself
               	 $spamcheck = ''; // Spam check

        if(isset($_POST['send']))
        {
             $name     = $_POST['name'];
             $email    = $_POST['email'];
 $course   = $_POST['course'];
             $subject  = $_POST['subject'];
             $message  = $_POST['message'];
           	 $spamcheck = $_POST['spamcheck'];

            if(trim($name) == '')
            {
                $error = '<div class="errormsg">Please enter your name!</div>';
            }
        	    else if(trim($email) == '')
            {
                $error = '<div class="errormsg">Please enter your email address!</div>';
            }
            else if(!isEmail($email))
            {
                $error = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>';
            }
        	    if(trim($subject) == '')
            {
                $error = '<div class="errormsg">Please enter a subject!</div>';
            }
        	else if(trim($message) == '')
            {
                $error = '<div class="errormsg">Please enter your message!</div>';
            }
          	else if(trim($spamcheck) == '')
            {
            	$error = '<div class="errormsg">Please enter the number for Spam Check!</div>';
            }
          	else if(trim($spamcheck) != '5')
            {
            	$error = '<div class="errormsg">Spam Check: The number you entered is not correct! 2 + 3 = ???</div>';
            }
            if($error == '')
            {
                if(get_magic_quotes_gpc())
                {
                    $message = stripslashes($message);
                }

                // the email will be sent here
                // make sure to change this to be your e-mail

                $to      = "example@example.com"; "example2@example2.com"

                // the email subject
                // '[Contact Form] :' will appear automatically in the subject.
                // You can change it as you want

                $subject = '[Registration] : ' . $subject;

                // the mail message ( add any additional information if you want )
                $msg     = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n\n : $course \r\n\n". "Message : \r\n$message";

                mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");


				// autoresponder subject
				$subject2 = 'Course Registration Confirmation: Thank you for your registration';

				// autoresponder message
				$msg2	="Dear $name \r\n\nThank you for registering to attend our $course course.\r\n\If you need any further assistance, please don't hesitate to contact us:\r\n\nEmirates Enterprise\r\n1622, One Sentral, Jln Sentral Stesen 5,\r\n KL Sentral, 50470, KL\r\n";

				mail($email, $subject2, $msg2, "From: $to\r\nReply-To: $to\r\nReturn-Path: $to\r\n");			
					?>

Can someone help me with detecting what the problem is? Is some line used in this php script outdated or something?

    This line is the problem:

                        $to      = "example@example.com"; "example2@example2.com"
    

    What the solution is depends on what you intended, but I suspect you want to either delete or comment everything after the semi-colon?

      Well, it was indeed one email address, I was actually trying to put in a second one to receive the notification at two different addresses.

      If this is not the way to go around it, how should I put it? And why is it that the syntax fault is insisting on the "$subject" line rather than the "$to" line?

      Thanks so much for your help.

        The error is generated at the point where the parser is unable to figure out what you want and throws up its hands in disgust and quits. 😉

        As PHP allows multiple commands on the same line, separated by semi-colons, the line above is not necessarily incorrect syntax-wise. It is not until the parser gets to the next non-comment line where it runs into the variable $subject, which does not make sense following that string literal without some sort of operator between them, and thus the unexpected variable error.

        Anyway, if you want the "To:" address to be two email addresses, put them together in the same set of quotes, comma-separated:

        $to      = "example@example.com, example2@example2.com";
        
          Write a Reply...