2012-02-03 119 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

相关问题