什么是“资源#"? [英] What are "Resource#'s"?

查看:15
本文介绍了什么是“资源#"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打印以下变量时,我得到了 Resource#6 和 Resource#7:

I am getting Resource#6 and Resource#7 when I print the following variables:

$salty_password = sha1($row['salt'], $_POST['password']);

if(isset($_POST['subSignIn']) && !empty($_POST['email']) && !empty($_POST['password'])) {


    $query =  "SELECT `salt` FROM `cysticUsers` WHERE `Email` = '" . $_POST['email'] . "'";
    $request = mysql_query($query,$connection) or die(mysql_error());
    $result = mysql_fetch_array($request);



    $query2 = "SELECT * FROM `cysticUsers` WHERE `Email` = '". $_POST['email']."' AND `Password` = '$salty_password'";
    $request2 = mysql_query($query2,$connection) or die(mysql_error());
    $result = mysql_fetch_array($request2);

    print_r($request);
    print_r($request2);

if(@mysql_num_rows($request,$request2)) {


        $_SESSION['CLIFE']['AUTH'] = true;
        $_SESSION['CLIFE']['ID'] = $result['id'];

        // UPDATE LAST ACTIVITY FOR USER
        $query = "UPDATE `cysticUsers` SET `LastActivity` = '" . date("Y-m-d") . " " . date("g:i:s") . "' WHERE `id` = '" . mysql_real_escape_string($_SESSION['CLIFE']['ID']) . "' LIMIT 1";
        mysql_query($query,$connection);


        if(!empty($_POST['return'])) {
            header("Location: " . $_POST['return']);

        }else{
            header("Location: CysticLife-Dashboard.php?id=" . $_SESSION['CLIFE']['ID']);
            }
        }

    }else{

        $_SESSION['CLIFE']['AUTH'] = false;
        $_SESSION['CLIFE']['ID'] = false;

    }


?>

试图解决这个代码块,但不确定这意味着什么.我正在尝试使用经过哈希和加盐处理后注册的明文密码重新登录.我觉得我很接近,但有些地方有点不对劲.也非常感谢您提供有关为什么这不起作用的帮助.

Trying to troubleshoot this code chunk and not sure what that means. I am trying to sign back in with the clear text password I signed up with after its been hashed and salted. I feel like I'm very close but something is slightly wrong. Help on why that is not working would be greatly appreciated as well.

提前致谢

推荐答案

mysql_query()resource (就 PHP OOP 代码而言,它们不是 objects,但我想不出更好的词了).这些包含只能由某些函数读取的二进制数据,例如 mysql_fetch_*() 函数.

mysql_query() returns result sets as objects of type resource (they're not objects in terms of PHP OOP code but I can't think of a better word). These contain binary data that can only be read by certain functions, for example the mysql_fetch_*() functions.

要调试 MySQL 查询,您应该使用 mysql_error()mysql_errno() 检查错误和/或将 SQL 语句保存在变量中并打印出来.

To debug your MySQL queries you should check for errors using mysql_error() and mysql_errno() and/or save your SQL statements in variables and print those.

据我所知,您正在执行两个查询,但覆盖了相同的 $result 变量,而对第一个没有做任何事情.此外,mysql_num_rows() 一次只能计算一个结果集,因此您不能将两个结果集传递给同一个调用.

From what I see, you're performing two queries but overwriting the same $result variable, without doing anything about the first. Also, mysql_num_rows() can only count one result set at a time, so you can't pass two result sets into the same call.

这篇关于什么是“资源#"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆