最后关闭数据库时,提示语法错误,新手问题,谢谢
程序员文章站
2022-04-01 18:28:53
...
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in F:\www\study\authmain.php on line
session_start();
if (isset($_POST['userid']) && isset($_POST['password']))
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$db_conn=new mysqli('localhost','webauth','webauth','auth');
if (mysqli_connect_errno()) {
echo 'Connection to database failed:'.mysqli_connect_error();
exit();
}
$query='Select * from authorized_users where name='. $userid." and password=sha1('$password')";
$result=$db_conn->query($query);
if ($result->num_rows)
{
$_SESSION['valid_user']=$userid;
}
$db_conn->close();
}
?>
session_start();
if (isset($_POST['userid']) && isset($_POST['password']))
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$db_conn=new mysqli('localhost','webauth','webauth','auth');
if (mysqli_connect_errno()) {
echo 'Connection to database failed:'.mysqli_connect_error();
exit();
}
$query='Select * from authorized_users where name='. $userid." and password=sha1('$password')";
$result=$db_conn->query($query);
if ($result->num_rows)
{
$_SESSION['valid_user']=$userid;
}
$db_conn->close();
}
?>
回复讨论(解决方案)
提示哪行出错
请指出出现错误的行号
最后一行close
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in F:\www\study\authmain.php on line 23
最后多了个分号
写错了,是多了个括号,最后的括号去掉。
写错了,是多了个括号,最后的括号去掉。
谢谢!