PDA

View Full Version : Help with MySQL


S4t3K
22/02/2014, 10:23 AM
Hi.

I use a_mysql include and mysql.dll plugin by BlueG (R7 version) and I would know two things.

First, how to launch a query, and also how to optimize my queries.

Thank for the one who'll answer.

Crazydriver
22/02/2014, 10:36 AM
Bro Read this Thread: http://forum.sa-mp.com/showthread.php?t=129183

Konstantinos
22/02/2014, 10:38 AM
http://forum.sa-mp.com/showthread.php?t=337810

Bro Read this Thread: http://forum.sa-mp.com/showthread.php?t=129183

That's not for R7.

S4t3K
22/02/2014, 11:01 AM
I've done queries based on this model


new idx;
while(idx < sizeof(InfoMaison))
{
format(query, 1024, "ALTER TABLE Maisons WHERE `id`='%d' MODIFY `xEntree` DOUBLE NOT NULL '%f'", idx, InfoMaison[idx][xEntree]);
mysql_query(query);
}


But I got "error 035: argument type mismatch (argument 1)" on the line mysql_query

Someone has an idea (#BigNoobInSQL)

Konstantinos
22/02/2014, 11:07 AM
It seems your version of a_mysql.inc is not for R7 but one of the latest version which mysql_query uses connection handle is first argument and the query (array) is the second argument.

S4t3K
22/02/2014, 11:11 AM
Do you have the version which mysql_query doesn't use handles ?

It's quite boring because I just use one MySQL connection...

Crazydriver
22/02/2014, 11:12 AM
I got the same error when i started to script my GM but when i downgraded it to Mysql R6 it worked try using Mysql R6 package

S4t3K
22/02/2014, 11:14 AM
Thanks, I'll test now and i'll edit this post to tell you what happened :)

EDIT : Same with R6.

In the include, the native is


native mysql_query(query[],resultid = (-1),extraid = (-1),connectionHandle = 1);

So the query is called first.

Crazydriver
22/02/2014, 11:35 AM
You get these error at compiling or after starting your server.exe??? and if so post your Server.cfg file here

S4t3K
22/02/2014, 11:36 AM
Just while compiling

Smally
22/02/2014, 11:43 AM
use mysql_query(connectionHandleName, query);

Crazydriver
22/02/2014, 11:46 AM
Are you using the .inc and plugin which comes in a same package ???? Also show us the Error's and The codes...

S4t3K
22/02/2014, 11:53 AM
Strangely, now the queries are good (think it was a bug with the connect, solved because i use to solve bugs when i find them, now another one :3)

mysql_get_field got me errors now -.-

the whole function


public ChargerMaisons()
{
format(query, 1024, "SELECT * FROM Maisons");
mysql_query(query);
mysql_store_result();

while(mysql_retrieve_row())
{
new idx = 0;
while(idx < sizeof(InfoMaison))
{
new propname[MAX_PLAYER_NAME+1], Float:x, Float:y, Float:z, Float:tx, Float:ty, Float:tz, pos;
new loc, tloc, tprixl, prixl, tnloc, nloc;
new tcp, cp, tsp, sp, tap, ap, defaultd, prix;

mysql_get_field("xEntree", tx); // Error
x = floatstr(tx); // Error
mysql_get_field("yEntree", ty); // Error
y = floatstr(ty); // Error
mysql_get_field("zEntree", tz); // Error
z = floatstr(tz); // Error
AddStaticPickup(1273, 2, x, y, z, 0);

mysql_get_field("posseder", pos); // Error
if(pos == 0)
{
mysql_get_field("defaultd", defaultd); // Error
mysql_get_field("prix", prix); // Error
InfoMaison[idx][mDefaultd] = defaultd;
InfoMaison[idx][mPrix] = prix;
format(texte, 1024, "Maison vendre\n%s. \nPrix : %d$", defaultd, prix);
InfoMaison[idx][mDesc] = CreateDynamic3DTextLabel(texte, 0x07BB00FF, x, y, z+1, 10.0, 0, 0);
}
else
{
mysql_get_field("proprio", propname);
InfoMaison[idx][mProprio] = propname;
UnderscoreToSpace( propname );
format(texte, 1024, "Maison de %s", propname);
InfoMaison[idx][mDesc] = CreateDynamic3DTextLabel(texte, 0x07BB00FF, x, y, z+1, 10.0, 0, 0);
}

InfoMaison[idx][xEntree] = x;
InfoMaison[idx][yEntree] = y;
InfoMaison[idx][zEntree] = z;
InfoMaison[idx][mPhrase] = texte;
InfoMaison[idx][mProprio] = propname;

mysql_get_field("location", tloc); // Error
loc = strval(tloc); // Error
InfoMaison[idx][mLocation] = loc;

mysql_get_field("prix_location", tprixl); // Error
prixl = strval(tprixl); // Error
InfoMaison[idx][mPrixLocation] = prixl;

mysql_get_field("nombre_locataires", tnloc); // Error
nloc = strval(tnloc); // Error
InfoMaison[idx][mNombreLocataires] = nloc;

mysql_get_field("coffre_pos", tcp); // Error
cp = strval(tcp); // Error
InfoMaison[idx][mCoffrePos] = cp;

mysql_get_field("sante_pos", tsp); // Error
sp = strval(tsp); // Error
InfoMaison[idx][mSantePos] = sp;

mysql_get_field("armure_pos", tap); // Error
ap = strval(tap); // Error
InfoMaison[idx][mArmurePos] = ap;

idx++;
}
}

mysql_free_result();
return 1;
}

Same error each time "error 035: argument type mismatch (argument 1)"

S4t3K
22/02/2014, 01:18 PM
Up
4chars

venomlivno8
22/02/2014, 01:38 PM
It would be better for your script to use R37 plugin because it has threaded queries and I can help you about it.

S4t3K
22/02/2014, 01:46 PM
I take all solutions which exists.

Link please ^^ (and i won't deny some help)

venomlivno8
22/02/2014, 01:50 PM
https://github.com/pBlueG/SA-MP-MySQL/releases/tag/R37 here's the link and if you have xfire add me it will be easier, my xf username is venomli

S4t3K
22/02/2014, 02:01 PM
don't know xfire ^^
I use skype, add light.ning. (Displayed name : # • ๖ۣۜS4T3K™ ~ [α > Ω], profile photo is Booba (french rapper)

Thanks in advance

venomlivno8
22/02/2014, 02:02 PM
Will do, can't right now, tomorrow(GMT+1)

S4t3K
22/02/2014, 02:10 PM
I am also on GMT+1 and it's just 4 PM :3