collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: mysql_fetch_array Bug in PHP5 CLI processor.  (Read 10516 times)

0 Members and 2 Guests are viewing this topic.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
mysql_fetch_array Bug in PHP5 CLI processor.
« on: May 13, 2006, 12:44:13 pm »
I've discovered if your using PHP 5 there may be a bug with it. I know some of you may have seen this lately if you've moved to PHP5.
Fatal error: Cannot use string offset as an array in... etc. etc.

 For some unknown reason and I havn't figured out why yet, but from reading around in various PHP dev forums when you get a mysql_fetch_array result set back from a function used in a Foreach loop the array offsets get screwed up. One work around for it is if you're using PHP5 is to write another function that converts the returned mysql array to a defined array.

For an Example of defined array function I had to write to get rid of that string offset error see the TowerAttack.php I posted not long ago and look for function get_lcainfo($zone, $x, $y)

I'm currently looking at a way to re-write the function select($sql) in MySQL.php to build a defined array to return on the fly as a work around so I don't have to keep writing custom defined array functions for all my modules that use the select function in a for or foreach loop.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #1 on: May 13, 2006, 02:15:49 pm »
Any idea if this is limited to specific versions or resolved in latest php 5.1 releases?
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #2 on: May 13, 2006, 02:25:52 pm »
Well so far I've got the same Fatal error in PHP5.1.2 thru PHP5.1.4 concerning this issue. I've still yet to check bugs.php.net to see if it's been reported yet.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #3 on: May 13, 2006, 02:31:18 pm »
Ok no time like the present and I don't know why I didn't do it sooner but it looks like a related issue.

http://bugs.php.net/bug.php?id=37001
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #4 on: May 13, 2006, 11:40:43 pm »
Well I guess that explains the bug in my boss module.
Eternalist
General of The Syndicate

Offline Nesi

  • BeBot User
  • **
  • Posts: 55
  • Karma: +0/-0
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #5 on: May 24, 2006, 08:45:40 am »
You must rewrite the MySQL.php to simply return the unaltered array you'd get from a normal query. The MySQL.php redos the original sql array before passing it back to the user. Which makes it unusable in any mysql_fetch_statements.

You can then for an example use
$members = $this -> bot -> db -> select_direct("SELECT * FROM members");
While ($member = mysql_fetch_assoc($members):
Echo $member["id"] . " - " . $member["nickname"];
Endwhile;

You can also explode the $member array so you'd get $id, $nickname and such.

Hope this made any sence :)

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 203
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal