I got this error when I was running some code:

Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in C:\xampp\htdocs\scanner\mine.php on line 31

Line 31 is:

      if($_POST['thename']) {

I'm getting it from:

  echo '<h6>Settings</h6>';
  echo '<form action="" method="post">';
  echo '<b>Name:</b> <input type="text" name="thename" />';
  echo '<br /><input type="submit" value="Submit" />';
  echo '<hr><br />'

What's causing the parse error?

share|improve this question

54% accept rate
2  
Look at the line of code above the if statement. – Danae Jul 13 '11 at 1:26
1  
Oh wow, I'm an idiot. Thanks guys, I did leave out the semi-colon. – Jacob Jul 13 '11 at 1:34
feedback

2 Answers

up vote 5 down vote accepted

This is typically because the line above is missing an ending semi-colon.

For example:

echo '<hr><br />';
share|improve this answer
feedback

Likely you left out a semicolon on the previous line, making php think that there was something more to the previous line and not expect an if statement.

share|improve this answer
+1 for the full explanation. – Jason McCreary Jul 13 '11 at 1:29
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.