SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 27/09/2010, 07:15 AM   #1
[L3th4l]
Guest
 
Posts: n/a
Default MySQL Problem..

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 )
 
Old 27/09/2010, 10:50 AM   #2
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 2,629
Reputation: 410
Default Re: MySQL Problem..

You are not giving a WHERE statement to update. If you are inserting it for the first time then use INSERT INTO
__________________
[HiC]TheKiller is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hey i have problem with C-MYSQL Please help! GBLTeam Help Archive 0 29/08/2010 08:50 PM
MySQL, problem bfkj Help Archive 2 19/04/2010 11:01 PM
[HELp]MySQL problem _GriLLeX_ Plugin Development 1 13/10/2009 08:35 AM
problem with CWRP in linux (mysql problem) BSMan Server Support 1 16/06/2009 02:36 PM
MYSQL Problem CyberGuerilla Help Archive 2 28/05/2009 01:24 PM


All times are GMT. The time now is 10:22 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.