可能重复:
使用全局变量作为数据源的 PHP 会话副作用警告
我通过 PHP 从 Ajax 获得响应。我收到此错误:
PHP 警告: 未知:您的脚本可能依赖于在 PHP 4.2.3 之前存在的会话副作用。请注意,除非启用了 register_globals,否则会话扩展不会将全局变量视为数据源。您可以通过分别在第 0 行的未知中将 session.bug_compat_42 或 session.bug_compat_warn 设置为 off 来禁用此功能和此警告
我该如何解决?
我的 PHP 脚本是
<?php
include("include/config.inc.php");
$name = $_POST['loginname'];
$phone = $_POST['logintelephone'];
// To protect MySQL injection
$name = stripslashes($name);
$phone = stripslashes($phone);
$name = mysql_real_escape_string($name);
$phone = mysql_real_escape_string($phone);
$query = mysql_query("select * from chatapp_users where name = '$name' and phone_no = '$phone'");
// Mysql_num_row is counting table row
$count=mysql_num_rows($query);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count > 0){
$result = mysql_fetch_array($query);
session_start();
$_SESSION['currentuser'] = $name;
$_SESSION['currentuserid'] = $result['user_id'];
$_SESSION['phone'] = $result['phone'];
echo 1;
}else {
echo 2;
}
?>