2012-02-03 181 views
9

我似乎無法找到我的代碼出錯的地方。這是我的全部錯誤:語法錯誤,意外T_VARIABLE

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

但我一直在尋找一個小時的線。我會給你整個代碼導致我的新手大腦無法找到的錯誤:

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

希望能幫到你,如果你需要更多的信息只是讓我知道。

這裏是額外的代碼

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){ 
     /* ... */ 

編輯:

我仍然得到重大錯誤回報我會給代碼,你可以告訴我缺少

+0

你可以提供一些周圍的代碼嗎?該錯誤可能是因爲前一行有錯字。 – templatetypedef 2012-02-03 21:36:36

+0

@templateypedef IPut額外的代碼是需要的 – 2012-02-03 21:38:04

+0

@CoryFournier你可以編輯你的問題。 -_- – jn1kk 2012-02-03 21:40:18

回答

32

沒有分號該指令的結尾導致錯誤。

編輯

像RiverC指出的那樣,在上一行的末尾沒有分號!

require ("scripts/connect.php") 

編輯

看來你有沒有分號任何責任。

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.

+2

或者以前的行缺少逗號或分號。 – 2012-02-03 21:37:55

+0

看起來像缺少分號。 – skyburner 2012-02-03 21:40:47

+0

意外(或不)以下行也缺少分號。 Cory,你好! PHP不是JavaScript!分號不是可選的。 – Mchl 2012-02-03 21:41:53

0

如果是整條生產線,非常好可能是因爲你在該行的末尾缺少;

+0

太糟糕了PHP解析器不會告訴OP。 – 2012-02-03 21:56:30

相關問題