php 解析错误:语法错误,意外的 T_RETURN

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

Parse error: syntax error, unexpected T_RETURN

phpsql

提问by user1043816

Getting this Problem. Tried my best, I looked up some stuff and they said that it could be the line above the error line (btw the error line is the "return mysql_insert_id();). Any help?

得到这个问题。尽我所能,我查了一些东西,他们说它可能是错误行上方的那一行(顺便说一句,错误行是“return mysql_insert_id();”)。有帮助吗?

    function user_register($email, $name, $password) {
  $email = mysql_real_escape_string($email);
  $name = mysql_real_escape_string($name);
  mysql_query("INSERT INTO 'users' VALUES ('', '$email', '$name', '".md5 ($password)."')"
  return mysql_insert_id();
}

回答by AlienWebguy

Missing a closing paren:

缺少结束括号:

function user_register($email, $name, $password) {
    $email = mysql_real_escape_string($email);
    $name = mysql_real_escape_string($name);
    mysql_query("INSERT INTO 'users' VALUES ('', '$email', '$name', '".md5 ($password)."')");
    return mysql_insert_id();
}

回答by Daniel A. White

You forgot );after your query.

);在查询后忘记了。