12

I can't seem to find where my code has went wrong. Here is my full error:

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\GigaLoad.com\register.php on line 102

But I've been looking a that line for hours. I will give you the entire code cause my newbie brain cant find the error:

$query = mysql_query("SELECT * FROM users WHERE username='$username'")

Hope you can help if you need more info just let me know.

Here Is The Extra Code

 if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >=6)){
   require ("scripts/connect.php")
   $query = mysql_query("SELECT * FROM users WHERE username='$username'") // <-- Error here
   $numrows = mysql_num_rows ($query)
   if ($numrows == 0){
        /* ... */

EDIT:

I am still getting major erros i will give the code and can you tell what i am missing

5
  • Can you give some of the surrounding code as well? The error might be because of a typo on a previous line. Commented Feb 3, 2012 at 21:36
  • @templateypedef IPut The Extra Code Is That Enought Commented Feb 3, 2012 at 21:38
  • @CoryFournier You can edit your question. -_-
    – jn1kk
    Commented Feb 3, 2012 at 21:40
  • thanks @RiverC but i just go an error on the 103 line and i added the semi-colon Commented Feb 3, 2012 at 21:44
  • This fixed my error over a year later, idk why this was closed
    – Stephan
    Commented Jul 10, 2013 at 16:03

2 Answers 2

41

There is no semicolon at the end of that instruction causing the error.

EDIT

Like RiverC pointed out, there is no semicolon at the end of the previous line!

require ("scripts/connect.php") 

EDIT

It seems you have no-semicolons whatsoever.

http://php.net/manual/en/language.basic-syntax.instruction-separation.php

As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement.

5
  • 3
    Or the line previous is missing a comma or semicolon.
    – user1086498
    Commented Feb 3, 2012 at 21:37
  • Looks like missing semicolons. Commented Feb 3, 2012 at 21:40
  • And accidentaly (or not) the following line is also missing a semicolon. Hello Cory! PHP is not JavaScript! Semicolon is NOT optional.
    – Mchl
    Commented Feb 3, 2012 at 21:41
  • kk well i am new to this so thanks i was following a tut and i got confused Commented Feb 3, 2012 at 21:47
  • Show error with line number php -d display_errors=1 -l foo.php Commented Mar 13, 2019 at 10:33
2

If that is the entire line, it very well might be because you are missing a ; at the end of the line.

1
  • Too bad the PHP parser won't just tell the OP that.
    – Ira Baxter
    Commented Feb 3, 2012 at 21:56

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