gpt4 book ai didi

php - mysql 表字段 - 资源 ID #7

转载 作者:行者123 更新时间:2023-11-29 04:27:51 24 4
gpt4 key购买 nike

<分区>

我在数据库中有下表:

id, username, email, old_ip, current_ip

每次用户登录时,我希望将他们当前的 ip 存储在 current_ip 中。但在此之前,我想保存他们的 old_ip(来自上次登录),所以我想我可以在将新数据复制到 current_ip 之前将 current_ip 中的内容移动到 old_ip。

我在登录的时候写了这个脚本:

........
$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
// Get member ID into a session variable
$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;
// Get member username into a session variable
$username = $row["username"];
session_register('username');
$_SESSION['username'] = $username;


// IP getting
$old_ip = mysql_query("SELECT current_ip FROM members WHERE id='$id'");
$result_old_ip = $old_ip;
$sql_setoldip = mysql_query("UPDATE members SET old_ip='".$result_old_ip."' WHERE id='$id'");


$getip = getenv("REMOTE_ADDR");
$current_ip = $getip;
// Update ip in database
mysql_query("UPDATE members SET current_ip='".$current_ip."' WHERE id='$id'");

}

我在 old_ip 字段中得到的结果是“Resource id #7” 有什么帮助吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com