L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2008, 01:05:47 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: mysql_fetch_array Bug in PHP5 CLI processor.
Pages: [1]   Go Down
« previous next »
Print
Author Topic: mysql_fetch_array Bug in PHP5 CLI processor.  (Read 804 times)
0 Members and 1 Guest are viewing this topic.
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



mysql_fetch_array Bug in PHP5 CLI processor.
« on: May 13, 2006, 05:44:13 AM »

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.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #1 on: May 13, 2006, 07:15:49 AM »

Any idea if this is limited to specific versions or resolved in latest php 5.1 releases?
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #2 on: May 13, 2006, 07:25:52 AM »

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.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #3 on: May 13, 2006, 07:31:18 AM »

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
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Malosar
Expert
*****
Offline Offline

Posts: 259


WWW
Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #4 on: May 13, 2006, 04:40:43 PM »

Well I guess that explains the bug in my boss module.
Logged

Eternalist
General of The Syndicate
Nesi
Rookie
**
Offline Offline

Posts: 55


Re: mysql_fetch_array Bug in PHP5 CLI processor.
« Reply #5 on: May 24, 2006, 01: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 Smiley
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: mysql_fetch_array Bug in PHP5 CLI processor.
« previous next »
 
Jump to:  

Recent
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 2
Guests: 10
Total: 12
egrath
Temar

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.759 seconds with 29 queries. (Pretty URLs adds 0.029s, 4q)
Loading...