Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strict Standards: Resource ID#73 used as offset, casting to integer

Tags:

php

mysql

i fetch MySql result using this PHP function:

function fetcharray ($query_id)

    {
        if(!$query_id)
        {
            $query_id = $this->query_res;
        }

        if($query_id)

        {
            $this->q_array[$query_id] = @mysql_fetch_array($query_id,MYSQL_ASSOC); // LINE 124
            return $this->q_array[$query_id]; //LINE 125
        }

        else

        {
            return false;
        }
    }

Now, I move to PHP 5.5 and see This error:

Strict Standards: Resource ID#73 used as offset, casting to integer (73) in domain.com/includes/functions/db.php on line 124

Strict Standards: Resource ID#73 used as offset, casting to integer (73) in domain.com/includes/functions/db.php on line 125

How I can Fix this error?

like image 385
Pink Code Avatar asked Sep 05 '25 02:09

Pink Code


1 Answers

You're using a resource, which is not an integer, as an integer. Even though you see a number when you inspect it, it actually is not a true integer. It's a resource ID that is associated with your MySQL connection.

If you want to use it as an integer I think you can cast it to an integer before using it (I never actually tried it).

    if($query_id)
    {
        $id = (int) $query_id;

        $this->q_array[$id] = @mysql_fetch_array($query_id,MYSQL_ASSOC); // LINE 124
        return $this->q_array[$id]; //LINE 125
    }
like image 108
John Conde Avatar answered Sep 07 '25 21:09

John Conde