View Single Post
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-07-2019 , 10:38   insert into (or update) mysql fails because of special characters
Reply With Quote #1

Hey, how do I fix that problem? For example player's name is -*KURCZACY*- tesak
and console pops
Code:
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 ''5' at line 1
. (All players with normal names are uploaded correctly to database, so it is because of these special chars)

I have following codes to insert, update and select:

PHP Code:
new table1[] = "CREATE TABLE IF NOT EXISTS `codexp` ( `user` VARCHAR(33) NOT NULL , `trieda` INT NOT NULL , `level` INT NOT NULL , PRIMARY KEY (`user`)) ENGINE = InnoDB;" 

formatex(Querycharsmax(Query), "INSERT INTO `codexp` (`user`, `trieda`, `level`) VALUES ('%s-%i', '%i', '%i') ON DUPLICATE KEY UPDATE `level` = '%i'"nazwa_gracza[id], klasa_gracza[id], klasa_gracza[id], poziom_gracza[id], poziom_gracza[id]) 

formatex(Querycharsmax(Query), "SELECT * FROM codexp WHERE user='%s-%i'"nazwa_gracza[id], klasa_gracza[id])

formatex(Querycharsmax(Query), "UPDATE `codexp` SET `level` = '%i', `trieda` = '%i' WHERE `user` = '%s-%i';"poziom_gracza[id], klasa_gracza[id], nazwa_gracza[id], klasa_gracza[id]) 
I am also aware of that the problem can be caused by %s-%i dash, but how can I fix it, except by adding other character than dash?

Last edited by TheBladerX; 02-07-2019 at 10:53.
TheBladerX is offline