SA-MP Forums Archive
MYSQL Car system dosen't save - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL Car system dosen't save (/showthread.php?tid=577620)



MYSQL Car system dosen't save - malackovgfx - 12.06.2015

Hello again i have a problem. My cars don't save in mySQL database the code:

PHP код:
saveCarToDB(playerid,carid)
{
    new 
query[128];
    
format(querysizeof(query), "INSERT INTO cars (owner,x,y,z,r,model) VALUES ('%i',%f','%f','%f','%f','%i')",iInfo[playerid][db_id],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r],cInfo[carid][model]);
    
mysql_function_query(dbhandel,query,true,"carSaveToDB","i",carid);
    return 
1;

the code to give someone an car:
PHP код:
createPlayerCar(playeridmodelid,Float:xFloat:yFloat:zFloat:r)
{
    for(new 
i=0i<sizeof(cInfo); i++)
    {
        if(
cInfo[i][id_x]!=0)continue;
        
cInfo[i][owner]=iInfo[playerid][db_id];
        
cInfo[i][c_x]=x;
        
cInfo[i][c_y]=y;
        
cInfo[i][c_z]=z;
        
cInfo[i][c_r]=r;
        
cInfo[i][id_x] = CreateVehicle(modelidx,y,z,r, -1, -1, -1);
        
cInfo[i][model] = modelid;
        new 
string[128];
        
format(stringsizeof(string), "Automobil cInfo[%i] je napravljeno!",i);
        print(string);
        
saveCarToDB(playerid,i);
        return 
1;
    }
    return 
1;

and the MYSQL log
PHP код:
[22:08:22] [ERRORCMySQLQuery::Execute[carSaveToDB] - (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 '','-1482.304565','5.468750','121.948730','400')' at line 1
[22:08:57] [ERRORCMySQLQuery::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 'WHERE id='0'' at line 1
[22:12:11] [ERRORCMySQLQuery::Execute[carSaveToDB] - (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 '','-2045.110351','59.643882','345.670837','400')' at line 1
[22:12:28] [ERRORCMySQLQuery::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 'WHERE id='0'' at line 1 
my table


Re: MYSQL Car system dosen't save - AndySedeyn - 12.06.2015

I believe and could be wrong, but the single quotation mark is used for strings. Not for (floating) integer values.


Re: MYSQL Car system dosen't save - Konstantinos - 12.06.2015

What AndySedeyn said is true, it's not obligatory to use it in integers/floats.

Anyway, your mistake is that you are missing '

VALUES ('%i',%f','%f','%f','%f','%i')


Re: MYSQL Car system dosen't save - malackovgfx - 12.06.2015

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
I believe and could be wrong, but the single quotation mark is used for strings. Not for (floating) integer values.
Thanks both of you, i'm gonna try it


Re: MYSQL Car system dosen't save - malackovgfx - 12.06.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
What AndySedeyn said is true, it's not obligatory to use it in integers/floats.

Anyway, your mistake is that you are missing '

VALUES ('%i',%f','%f','%f','%f','%i')
Nope, it dosen't work again the mysql log is the same :/


Re: MYSQL Car system dosen't save - Konstantinos - 12.06.2015

In the mysql logs, the error is in "x" field - the one I told you.

pawn Код:
"INSERT INTO cars (owner,x,y,z,r,model) VALUES (%i,%f,%f,%f,%f,%i)"
Or even like this (only for your current table structure):
pawn Код:
"INSERT INTO cars VALUES (NULL,%i,%f,%f,%f,%f,%i)"



Re: MYSQL Car system dosen't save - malackovgfx - 12.06.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
In the mysql logs, the error is in "x" field - the one I told you.

pawn Код:
"INSERT INTO cars (owner,x,y,z,r,model) VALUES (%i,%f,%f,%f,%f,%i)"
Or even like this (only for your current table structure):
pawn Код:
"INSERT INTO cars VALUES (NULL,%i,%f,%f,%f,%f,%i)"
Now i get this
PHP код:
[23:23:10] [ERRORCMySQLQuery::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 'WHERE id='0'' at line 1 



Re: MYSQL Car system dosen't save - AndySedeyn - 12.06.2015

That MySQL error has nothing to do with the code you have shown us. Show us the corresponding code for that error and we'll try to help you.


Re: MYSQL Car system dosen't save - malackovgfx - 12.06.2015

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
That MySQL error has nothing to do with the code you have shown us. Show us the corresponding code for that error and we'll try to help you.
It works now thank you guys <3