Liberty Unleashed

Scripting => Script Help => Topic started by: JamesConway on June 20, 2015, 11:31:20 pm

Title: mysql_fetch_assoc
Post by: JamesConway on June 20, 2015, 11:31:20 pm
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
Title: Re: mysql_fetch_assoc
Post by: SugarD on July 08, 2015, 04: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.
Title: Re: mysql_fetch_assoc
Post by: Vortrex on July 13, 2015, 01: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 (http://pastebin.com/raw.php?i=M1D7jAcY)
It may seem a bit excessive, but you can never be too careful I guess.
Title: Re: mysql_fetch_assoc
Post by: JamesConway on July 22, 2015, 10: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.
Title: Re: mysql_fetch_assoc
Post by: Vortrex on July 22, 2015, 09: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.
Title: Re: mysql_fetch_assoc
Post by: SugarD on August 18, 2015, 10: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.