答案 0 :(得分:8)
答案 1 :(得分:0)
你好,你初始化了一个新的会话。以下对我来说非常合适。
public static function insert_search($pdo)
{
@session_start();
$ip = $_SERVER['REMOTE_ADDR'];
$username = $_SESSION['username'];
//$username = self::username();
$date = date('Y-m-d');
//Adding the total searches for the logged in user
$query = $pdo->query("UPDATE `users` SET `total_searches` = `total_searches` +1 WHERE username = '$username'");
}
/* What you could potentially do is the following.
Make sure if you're doing it the procedural way
you put @session_start(); at the top of the page */
@session_start();
$sql = "UPDATE tbl SET amt_field ='amt_field' +1 WHERE username ='" .mysql_real_escape_string($_SESSION['username']). "'";
mysql_select_db('db',$con);
mysql_query($sql,$con);