[MYSQL] Load informations
#1

Hi,

I want to save informations then load them after.
The save system work. But I can't load them, I don't know why.

I did this:

Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `joueurs` WHERE `posX` = '%f', `posY` = '%f' AND `posZ` = '%f' WHERE `Name` = '%s'  ", pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ],  Name[playerid]);
mysql_tquery(mysql, query, "", "");
printf("\n %s", query); // printing to make sure the co-ords are being sent. );
But it doesn't work...

This is what I want:
I save in the database informations, then I load them to use them after.

Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `joueurs` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Argent`, `posX` ,`posY`, `posZ`, `Interieur`, `World`, `Skin`, `Niveau`) VALUES ('%e', '%s', '%s', 0, 0, 1000, 1527.5634, -1738.9218, 13.5469, 0, 0, 26, 1)", Name[playerid], pInfo[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "", "");

mysql_format(mysql, query, sizeof(query), "SELECT * FROM `joueurs` WHERE `posX` = '%f', `posY` = '%f' AND `posZ` = '%f' WHERE `Name` = '%s'  ", pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ],  Name[playerid]);
mysql_tquery(mysql, query, "", "");
printf("\n %s", query); // printing to make sure the co-ords are being sent. );

In server log:
Код:
 SELECT * FROM `joueurs` WHERE `posX` = '0.000000', `posY` = '0.000000' AND `posZ` = '0.000000' WHERE `Name` = 'Belabbas_Anis'  
[23:06:18] 0.000000 0.000000
So it doesnt load informations.

mysql logs:
Код:
[23:06:18] [DEBUG] mysql_format - connection: 1, len: 1024, format: "INSERT INTO `joueurs` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Argent`, `posX` ,`posY`, `posZ`, `Interieur`, `World`, `Sk..."
[23:06:18] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `joueurs` (`Username`, `Password`, `IP`, `Admin`, `V", callback: "(null)", format: "(null)"
[23:06:18] [DEBUG] mysql_format - connection: 1, len: 1024, format: "SELECT * FROM `joueurs` WHERE `posX` = '%f', `posY` = '%f' AND `posZ` = '%f' WHERE `Name` = '%s'  "
[23:06:18] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `joueurs` WHERE `posX` = '0.000000', `posY` = '0.0", callback: "(null)", format: "(null)"
[23:06:18] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:06:18] [DEBUG] CMySQLQuery::Execute[] - query was successful
[23:06:18] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[23:06:18] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:06:18] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `posY` = '0.000000' AND `posZ` = '0.000000' WHERE `Name` = 'Belabbas_Anis'' at line 1
I can see that there's an error but I don't know how to solve it.

You got an idea please ?

Thank you.
Reply
#2

Comparing floating point values is extremely unreliable due to the way they are handled and stored. I don't even know why you'd want to do that.
Also, your query is just wrong because you have two WHERE clauses.
Reply
#3

If it's extremely unreliable, how can I load posX,Y,Z from a database ?

How should me quiery be ?
Like that ? :

Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `joueurs` WHERE `posX` = '%f', `posY` = '%f' AND `posZ` = '%f',  `Username` = '%s'  ", pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ],  Name[playerid]);
Reply
#4

Things that you want to load go after SELECT. Have you been using 'SELECT *' all the time? 'SELECT *' means select everything.

PHP код:
SELECT posXposYposZ FROM `joueursWHERE `Username` = '%s' 
Reply
#5

Thank you,


So i tried this:

Код:
mysql_format(mysql, query, sizeof(query), "SELECT `posX` = '%f', `posY` = '%f',  `posZ` = '%f' FROM `joueurs` WHERE `Username` = '%s'   ", pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ],  Name[playerid]);
and this:

Код:
mysql_format(mysql, query, sizeof(query), "SELECT posX, posY, posZ FROM `joueurs` WHERE `Username` = '%s' ", pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ],  Name[playerid]);
But it still doesn't work.


Should I do it differently ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)