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?
September 07, 2008, 11:02:20 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 721 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
Help with online info in ...
by Barlyman
[Today at 07:56:24 PM]

BeBot v0.5.3 released (de...
by Temar
[Today at 07:51:18 PM]

Security
by Alreadythere
[September 06, 2008, 10:02:42 AM]

Probs with relay from gue...
by Temar
[September 06, 2008, 09:03:06 AM]

Raid spam in guild chat
by Temar
[September 06, 2008, 09:01:18 AM]

Org Relaying
by Nytridr
[September 06, 2008, 01:34:35 AM]

Link 2 Guilds via 2 Bots?
by Temar
[September 05, 2008, 04:22:40 PM]

SVN download
by clashbot
[September 05, 2008, 05:12:59 AM]

TWC
by Temar
[September 05, 2008, 12:27:23 AM]

How to find the guild ID?...
by Irinir
[September 03, 2008, 02:58:54 PM]
Stats
Members
Total Members: 965
Latest: morisey
Stats
Total Posts: 10414
Total Topics: 1413
Online Today: 18
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 5
Guests: 23
Total: 28
egrath
blackspell
paranoiak
Zeephonz
Barlyman

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