parse error, syntax error unexpected $end in line 25

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ambo2011
    New Member
    • Nov 2011
    • 6

    parse error, syntax error unexpected $end in line 25

    Code:
    <HTML>
    <?php
    if($submit)
    	{
    	$db = mysql_connect("localhost", "root","");
    	mysql_select_db("learndb",$db);
    	$sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary)
    	VALUES ('$first','$last','$nickname','$email','$salary')";
    	$result = mysql_query($sql);
    	echo "Thank you! Information entered.\n";
    	}
    else
    	{
    	?>
    	<form method="post" action="input.php">
    	First name:<input type="Text" name="first"><br>
    	Last name:<input type="Text" name="last"><br>
    	Nick Name:<input type="Text" name="nickname"><br>
    	E-mail:<input type="Text" name="email"><br>
    	Salary:<input type="Text" name="salary"><br>
    	<input type="Submit" name="submit" value="Enter information"></form>
    	<?
    	}
    ?>
    </HTML>
    Last edited by Rabbit; Nov 19 '12, 05:11 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Do you have short open tags turned on?

    Comment

    • ambo2011
      New Member
      • Nov 2011
      • 6

      #3
      Hi Rabbit,
      Thanks alot for your reply,

      I am a new programmer to PHP and I am not getting you when you say short open tags turned on.
      Please elaborate more

      Thanks
      I am really stack here

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        This is an open tag: <?php.
        This is a short open tag: <?.

        Unless you have it turned on, you can't use short open tags. Either turn it on or change your short open tag.

        Comment

        • ambo2011
          New Member
          • Nov 2011
          • 6

          #5
          Thanks a lot,

          It has worked.

          Comment

          • ambo2011
            New Member
            • Nov 2011
            • 6

            #6
            Hi Rabbit,
            I am getting another error: undefined variable: submit in input.php line 4

            Comment

            • omerbutt
              Contributor
              • Nov 2006
              • 638

              #7
              can you paste the code inside input.php
              regards,, iassume that your current code is from the same file and the $submit inside the if codition is what it is saying about , it cant find $submit is it the complete code
              Omer Aslam

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                That means the variable you're trying to use, $submit, doesn't exist. Maybe you named it something else. Or maybe you forgot to declare it. Whatever, the issue is, you need to look at the rest of your codeand see if it's been declared and initialized, if not, you need to do so.

                Comment

                Working...