MYSQL Car system dosen't save
#1

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
Reply
#2

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

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')
Reply
#4

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
Reply
#5

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 :/
Reply
#6

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)"
Reply
#7

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 
Reply
#8

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.
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)