Home  >  Article  >  Backend Development  >  php session对象创建报错,该如何处理

php session对象创建报错,该如何处理

WBOY
WBOYOriginal
2016-06-13 13:40:46763browse

php session对象创建报错
header("content-type:text/html;charset=utf-8");
include("conn.php"); 
session_start();
$Loname=trim($_POST["Loname"]);
$Lopass=trim($_POST["Lopass"]);
$Losx=trim($_POST["Losx"]);
$Locode=trim($_POST["Locode"]);

if (strlen($Locode)echo "请输入验证码";
exit;
}
if (trim($_SESSION['validationcode'])!=$Locode){
echo "验证码输入错误";
exit;
}
if (strlen($Loname)echo "请输入用户名";
exit;
}

if (strlen($Lopass)echo "请输入密码";
exit;
}

if (strlen($Losx)echo "请输入密令";
exit;
}
if ($Losx!="first_admin")
{
echo "密令错误";
exit;
}
mysql_query("set names utf8"); 
mysql_select_db("first_data",$con);
$Lopassx=md5($Lopass);
$sql="select * from admin_infox where admin_name='$Loname' and admin_pass='$Lopassx' and ck_working=1"; 
$result = mysql_query($sql);
$row=@mysql_num_rows($result); 
if (!$row){
echo "账号信息出错";
exit;
}
else
{
$_SESSION['admin_namex']=$result("admin_name");
$_SESSION['admin_power']=$result("admin_powerx");
$_SESSION['admin_cking']="working";header('location:index_home.php'); 
}
mysql_close($con);
?>

我验证用户之后创建session 结果报错说 

Fatal error: Function name must be a string in D:\wamp\www\first_line\administrators\inc\login_ck.php on line 49

高人指点指点 谢谢

------解决方案--------------------
$result("admin_name"); 这不对吧。 $result不是资源集吗、
------解决方案--------------------
$result是个数据库资源标识符,,所以你应该mysql_fetch_assoc……获取数据

然后获取$result("admin_name");数组元素下标用[]
------解决方案--------------------
$rowx["admin_name"]; 下面的一样。
------解决方案--------------------
$row = mysql_fetch_assoc($result); 

$_SESSION['admin_namex']=$row['admin_name'];
$_SESSION['admin_power']=$row['admin_powerx'];

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn