php 语法错误,意外的 T_VARIABLE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9135784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:14:02  来源:igfitidea点击:

syntax error, unexpected T_VARIABLE

phpsyntax-error

提问by Cory Fournier

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

解析错误:语法错误,C:\xampp\htdocs\GigaLoad.com\register.php 中的意外 T_VARIABLE 第 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

我仍然遇到重大错误,我将提供代码,你能告诉我我错过了什么吗

回答by jn1kk

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!

就像 RiverC 指出的那样,上一行的末尾没有分号!

require ("scripts/connect.php") 

EDIT

编辑

It seems you have no-semicolons whatsoever.

看来您没有任何分号。

http://php.net/manual/en/language.basic-syntax.instruction-separation.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.

与在 C 或 Perl 中一样,PHP 要求在每条语句的末尾以分号终止指令。

回答by LoveAndCoding

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

如果那是整行,那很可能是因为您;在行尾丢失了一个。