Author Topic: mysql_fetch_assoc  (Read 2113 times)

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
mysql_fetch_assoc
« on: June 21, 2015, 12:31:20 am »
Hello dear scripters,

For some reason this code crashes my server, is there any other way to get all rows from a mysql_fetch_assoc?

Code: [Select]
                                        local row;
while(row = mysql_fetch_assoc(result))
{
MessagePlayer(row["type"] + " " + row["rank"],   player, 255, 0, 0);
}

It only happens where there are more then 1 records in the database. I used the same example from the wikipedia. Result here is a mysql_query

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: mysql_fetch_assoc
« Reply #1 on: July 08, 2015, 05:27:45 pm »
I'm assuming you are using the MySQL plugin. If I remember correctly, it had a couple bugs in it which could result in issues like the one you have. Try the one listed on the wiki and see if that helps remedy your issue.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: mysql_fetch_assoc
« Reply #2 on: July 13, 2015, 02:37:53 am »
Strange. In all the time I've been using this plugin, I've never come across this issue.

I use mysql_fetch_assoc( ) all the time.

@JamesConway - Can you reply with a snippet that contains your query?

When I run a query, I always check to see if the returned result pointer actually exists. Sometimes running queries that have an issue with SQL syntax or some other problem causes issues. I also check to see if there are is at least one row before trying to use mysql_fetch_assoc().

Something like this: Pastebin Link
It may seem a bit excessive, but you can never be too careful I guess.

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
Re: mysql_fetch_assoc
« Reply #3 on: July 22, 2015, 11:01:59 am »
The problem was that the mysql plugin dll that gets shipped with the download is not the right one. I downloaded the sourcecode of the mysql plugin, compiled it myself and then it worked out fine.

I think that the latest update from the mysql plugin wasn't compiled with the download on the website.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: mysql_fetch_assoc
« Reply #4 on: July 22, 2015, 10:24:41 pm »
Yeah, there was a problem with this a while back too ... An issue with the original compile or something.

I think it was re-compiled by another member here at LU, which that version has worked just fine for me ever since.

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: mysql_fetch_assoc
« Reply #5 on: August 18, 2015, 11:46:16 pm »
I think it was re-compiled by another member here at LU, which that version has worked just fine for me ever since.
I believe Stormeus was the one who did that after we discovered this bug a very long time ago.

 

© Liberty Unleashed Team.