MySQL Problem..
#1

I'm studying MySQL, but here are some stuff that i don't understand..:

When the "Save" function gets called, it won't save that row in the mysql table. Altough the logs show it was successful.

Here i will show you a piece of code that saves and loads vehicles from mysql..

Here is the save part:
pawn Code:
new query[500];
    for(new i = 0;i<MAX_BUY_CAR;i++)
    {
        if(vSystem[i][vModel]!=0)
        {
            format(query, sizeof(query), "UPDATE `privatevehicles` SET `vModel` = '%d', `vSpawnX` = '%f', `vSpawnY` = '%f', `vSpawnZ` = '%f', `vSpawnA` = '%f', `vColor1` = '%d', `vColor2` = '%d', `vOwner` = '%s', `vPrice` = '%d'",

            vSystem[i][vModel],
            vSystem[i][x],
            vSystem[i][y],
            vSystem[i][z],
            vSystem[i][a],
            vSystem[i][vColor1],
            vSystem[i][vColor2],
            vSystem[i][owner],
            vSystem[i][vPrice]);
            mysql_query(query);
            mysql_free_result();
        }
    }
Here is the load part:
pawn Code:
new line[500];
    if(mysql_fetch_row(line))
    {
        for(new i = 0; i < MAX_BUY_CAR; i++)
        {
            new data[1];
            new data2[4];
            new Float:data3[4];
            sscanf(line, "p<|>dffffdds[24]d", data2[0], data3[0], data3[1], data3[2], data3[3], data2[1], data2[2], data[0], data2[3]);

            vSystem[i][vModel]  = data2[0];
            vSystem[i][x]       = data3[0];
            vSystem[i][y]       = data3[1];
            vSystem[i][z]       = data3[2];
            vSystem[i][a]       = data3[3];
            vSystem[i][vColor1] = data2[1];
            vSystem[i][vColor2] = data2[2];
            vSystem[i][owner]   = data[0];
            vSystem[i][vPrice]  = data2[3];
           
            if(vSystem[i][vModel]!=0)
            {
                created++;
                new car = CreateVehicle(vSystem[i][vModel],vSystem[i][x],vSystem[i][y],vSystem[i][z],vSystem[i][a],vSystem[i][vColor1],vSystem[i][vColor2],600000);
                Tunen(car);
                IDIS[car] = created;
            }
        }
        mysql_free_result();
    }
I created the table on the mysql database, here is the log when the 'Save' Function gets called:

Code:
[02:15:13] CMySQLHandler::Query(UPDATE `privatevehicles` SET `vModel` = '411', `vSpawnX` = '-1274.793823', `vSpawnY` = '-2115.607177', `vSpawnZ` = '24.693412', `vSpawnA` = '121.832946', `vColor1` = '65', `vColor2` = '2', `vOwner` = 'DealerCar', `vPrice` = '62452') - Successfully executed.

[02:15:13] >> mysql_free_result( Connection handle: 1 )
Reply
#2

You are not giving a WHERE statement to update. If you are inserting it for the first time then use INSERT INTO
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)