注意:会话已启动-忽略第2行C:\xampp\htdocs\teller\fungsi.php中的会话\u start()
我收到通知注意:会话已启动-忽略第2行C:\xampp\htdocs\teller\fungsi.php中的会话\u start(),php,session,Php,Session,我收到通知 Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\teller\fungsi.php on line 2 Notice: Use of undefined constant status - assumed 'status' in C:\xampp\htdocs\teller\fungsi.php on line 17 Notice: Use of unde
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\teller\fungsi.php on line 2
Notice: Use of undefined constant status - assumed 'status' in C:\xampp\htdocs\teller\fungsi.php on line 17
Notice: Use of undefined constant status - assumed 'status' in C:\xampp\htdocs\teller\fungsi.php on line 20
在我的代码中。我在旧版本中尝试了这个函数,我的sql版本成功了。但在我的sql版本5.5.16中,它不起作用。
这是我的源代码:
<?php
session_start();
function ver_user($username,$password)
{
mysql_connect('localhost', 'root', '');
mysql_select_db('teller');
if (!empty($username))
{
$query="SELECT * FROM `user` WHERE `username`='$username'";
$action=mysql_query($query);
$data=mysql_fetch_array($action);
$passmd5=md5($password);
if ($data['password']==$passmd5)
{
$_SESSION['username']=$username;
$_SESSION['password']=$password;
if ($data[status]==1){
$data['0']="valid";
}
if ($data[status]==2) {
$data['0']="valid1";
}
return $data;
}
else
{
$data['0']="invalid";
return $data;
}
}
}
function logout()
{
session_destroy();
}
?>
第二个和第三个警告是因为
$data[status]
应该是
$data['status']
问题中没有足够的信息来解释为什么会出现关于
会话\u start()
的警告。您需要检查更多代码,以找到在此之前调用的session\u start()
。这是一个include
文件吗?您是否在包含它的脚本中调用了session\u start()
?仅供参考,sql与您得到的通知毫无关系是的,我在包含它的脚本中调用了session\u start()。我清除了其中一个,然后成功了。谢谢你我想你是在之前的某个地方开始这个课程的。如果您使用的是includes,请确保调用一次session\u start()