php 解析错误:语法错误,意外的“$result”(T_VARIABLE)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13341057/
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-25 05:12:25  来源:igfitidea点击:

Parse error: syntax error, unexpected '$result' (T_VARIABLE)

phpmysql

提问by Art

I got a problem when I run the below code:

运行以下代码时遇到问题:

function newUser($email,$pwd,$pwd2,$firstname,$surname,$isAdmin=0){
  $email = $this->verify('Email',$email,10,40);
  $pwd = $this->verify('Password',$pwd,6,20);
  $pwd2 = $this->verify('Password',$pwd2,6,20);
  $firstname = $this->strToTitle($this->verify('Name',$firstname,2,40));
  $surname = $this->strToTitle($this->verify('Title',$surname,2,40));
  if ($pwd != $pwd2)
    return -1;
    $key=md5("secure")
  $result = $this->query("INSERT INTO user (email, pw, firstname, surname, isAdmin) VALUES (".$email.", AES_ENCRYPT(".$pwd.",".$key."), ".$firstname.", ".$surname.", ".$isAdmin.")");
  if (mysql_affected_rows()>0)
    return mysql_insert_id();
  else
    return 0;
}

It always prompt "Parse error: syntax error, unexpected '$result' (T_VARIABLE) in F:\xampp\htdocs\sql.php on line 76"

它总是提示“解析错误:语法错误,F:\xampp\htdocs\sql.php 中第 76 行出现意外的 '$result' (T_VARIABLE)”

Any one can keep me some advise?? Many thanks!!

任何人都可以给我一些建议?非常感谢!!

回答by Grant Thomas

A semi-colon is missing on the line assigning the result of the query to $result, it should be:

将查询结果分配给 的行上缺少分号$result,它应该是:

$key = md5("secure");

回答by Wayne Whitty

$key=md5("secure")

is causing the error. You forgot your semi-colon. This is why having an IDE with a built-in PHP parser will save you time and effort.

导致错误。你忘记了你的分号。这就是为什么拥有一个带有内置 PHP 解析器的 IDE 可以节省您的时间和精力。

回答by Leri

You are missing ;after $key=md5("secure").

之后你失踪;$key=md5("secure")

The easiest way to find out where you've missed semicolon is to look at the preceding line of the line where error occurred.

找出您遗漏分号的最简单方法是查看发生错误的行的前一行。