【问题标题】:syntax error, unexpected ';' [closed]语法错误,意外的 ';' [关闭]
【发布时间】:2013-07-21 09:13:13
【问题描述】:

我收到此错误:Parse error: syntax error, unexpected in /home/public_html/admin/login.php on line 15

<?PHP session_start();
$users = $_POST['txtuser'];
$passs = $_POST['txtpass'];
$passs= md5($passs);
include('../includes/myconnect.php');

$qry="SELECT * FROM users WHERE username='$users' and password='$passs'";
$res=mysql_query($qry);
$num=mysql_num_rows($res);
if($num>=1)
{
  $_SESSION['adminU']=$users;
  $_SESSION['adminP']=$passs;
  header("Location:emails.php");
}
else{header("Location:index.php?)msg=1";}
?>

如果我改变这个:

else{header("Location:index.php?)msg=1";}

到这里:

else{header("Location:index.php?msg=1");}

然后我得到这个错误:

   Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
 /home/...../public_html/admin/login.php on line 9

    Warning: Cannot modify header information - headers already sent by (output
 started at /home/...../public_html/admin/login.php:9) in
 /home/...../public_html/admin/login.php on line 15

【问题讨论】:

  • 阅读错误!以下是错误消息列表和故障排除说明:stackoverflow.com/questions/12769982/…
  • 你需要学习如何READ and debug错误信息。解决问题所需的一切都在错误消息中。
  • if(you use an IDE for PHP coding &amp;&amp; Format your code properly) Such mistakes will not occur anymore;
  • @CodeAngry 或者至少如果它们确实发生的话它们会很明显:)
  • 现在你得到的是一个 MySQL 错误。您能否回显您的查询语句并直接针对数据库运行它以查看它是否正确?

标签: php syntax syntax-error parse-error


【解决方案1】:

改变这个:

else{header("Location:index.php?)msg=1";}

到这里:

else{header("Location:index.php?msg=1");}

【讨论】:

  • 得到什么?这能解决您的问题吗?
  • 你能在你原来的问题中更新这个,因为这样更容易阅读吗?你现在遇到什么错误?
【解决方案2】:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
 /home/...../public_html/admin/login.php on line 9

此警告可能是因为您的查询返回的结果集为空。

【讨论】:

    猜你喜欢
    • 2012-03-10
    • 1970-01-01
    • 2013-11-11
    • 2013-01-10
    • 2012-02-26
    • 2012-10-03
    • 2014-04-02
    • 2011-10-26
    • 2014-09-02
    相关资源
    最近更新 更多