php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28612 Illegal offset type with mySQLi
Submitted: 2004-06-02 23:08 UTC Modified: 2004-06-03 08:36 UTC
From: jsgoupil at lookstrike dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.0.0RC2 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jsgoupil at lookstrike dot com
New email:
PHP Version: OS:

 

 [2004-06-02 23:08 UTC] jsgoupil at lookstrike dot com
Description:
------------
When trying to put a ressource of mySQLi in the index of an array, i get the following error : Warning: Illegal offset type in ...

I'm running PHP5.0.0RC2 and trying to connect a mySQL4.1 server.
When i try to connect the php_mysql.dll (not advanced) to another server, i don't get the "illegal offset" with the same code. (mysql_connect function)

Reproduce code:
---------------
<?php
$link = mysqli_connect("localhost","lookstrike","*****","lookstrike_local");
$query = mysqli_query($link,"SELECT player_id FROM ls_players");
$something = array();
$something[$query] = "1";
mysqli_close($link);
?>

Expected result:
----------------
It supposed to work like mySQL (not avanced)

Actual result:
--------------
Warning: Illegal offset type in ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-03 01:00 UTC] pollita@php.net
Resources cannot be used as array offsets.  This is just as true of mysql_connect() as it is of mysqli_connect().
 [2004-06-03 01:01 UTC] pollita@php.net
...or mysql_query()/mysqli_query() for that matter.
 [2004-06-03 02:54 UTC] jsgoupil at lookstrike dot com
it is working with the version mysql_query ! so, it's why i'm posting ... we can use a mysql_query ressource in offset but not with mysqli_query !
 [2004-06-03 08:36 UTC] derick@php.net
With mysql a resource gets silently converted to the ID (interger) of the resource, as in mysqli this resource is an Object, we can't convert it. Nevertheless, this is very ugly coding, and should never have worked in the first place, but *that* we can not fix due to BC reasons.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 20:01:29 2024 UTC