SA-MP Forums Archive
MySQL issue - 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 issue (/showthread.php?tid=443961)



MySQL issue - BigGroter - 14.06.2013

pawn Код:
format(szQuery, sizeof(szQuery), "INSERT INTO `Points` (`opCoX`, `opCoY`, `opCoZ`, `opCoA`) VALUES (%f, %f, %f, %f) WHERE `pID` = %d", positions[0], positions[1], positions[2], positions[3], id);
    mysql_function_query(dbHandle, szQuery, false, "thread_InsertPoint", "d", playerid);
I have this and get this error.
Код:
[17:05:44] [WARNING] CMySQLHandler::FreeResult() - The result is already empty.
[17:06:03] [ERROR] ProcessQueryThread(thread_InsertPoint) - 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 (`pID` = 6)' at line 1 (error ID: 1064)
What's the correct syntax, if not WHERE `pID` = %d or WHERE (`pID` =%d)?


Re: MySQL issue - LilBob - 14.06.2013

I think it's: WHERE ('ID' = %d)


Re: MySQL issue - BigGroter - 14.06.2013

No, it's not.


Re: MySQL issue - FunnyBear - 14.06.2013

Try this

pawn Код:
format(szQuery, sizeof(szQuery), "INSERT INTO Points (opCoX, opCoY, opCoZ, opCoA) VALUES ('%f', '%f', '%f', '%f') WHERE pID = '%d'", positions[0], positions[1], positions[2], positions[3], id);
        mysql_function_query(dbHandle, szQuery, false, "thread_InsertPoint", "d", playerid);



Re: MySQL issue - BigGroter - 14.06.2013

Isn't ' and ' used for strings? Like '%s'? I'll try it out in a bit though, thanks.


Re: MySQL issue - InfiniTy. - 14.06.2013

You can't use the "where" clause in a "insert" query..

(Do you need to insert a new line or just update an existing one ? For inserting a new line you use insert,and for updating an existing line you use UPDATE)


Re: MySQL issue - BigGroter - 14.06.2013

@InfiniTy. Thank you, that's how it's done.