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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Fri Nov 01 01:01:28 2024 UTC