Mysql Query Insert %s
#1

Hello,

I have made this script:
Код:
mysql_query("INSERT INTO `users` (`Name`, `Password`, `Admin`, `Money`, `Score`, `Language`) VALUES ('%s', '%s', '0', '10000', '0', '0')", PlayerInfo[playerid][pName], udb_hash(inputtext));
Whats wrong?
He insert by Name and Password this: %s And he must me insert the playername? (PlayerInfo[playerid][pName] is good)

Thanks.
Wouter0100.
Reply
#2

You need to format the query:
pawn Код:
new Query[150];
format(Query, 150, "INSERT INTO `users` (`Name`, `Password`, `Admin`, `Money`, `Score`, `Language`) VALUES ('%s', '%s', 0, 10000, 0, 0)", PlayerInfo[playerid][pName], udb_hash(inputtext));
mysql_query(Query);
And no need for the ' around integers, they are only needed for strings.
Reply
#3

Thanks for help!
Reply
#4

Whats Here wrong?
Код:
   if(inputtext != tmp) {
This error:
Код:
C:\Users\Wouter\Desktop\samp03bsvr_R2_win32\gamemodes\bare.pwn(326) : error 033: array must be indexed (variable "inputtext")
Reply
#5

you could use a string too
Reply
#6

udb_hash(inputtext) is an integer value i think .. use %d ... try like this
Reply
#7

pawn Код:
if(strcmp(tmp, inputtext, true) != 0)
Reply
#8

Grim_ Thanks, not work
Hornet kan je make that for me pleas?
Here's the code:
Код:
new tmp;
        mysql_query("SELECT `Password` FROM `users` WHERE `Name` = '%d'",PlayerInfo[playerid][pName]);
        tmp = mysql_store_result();
       if(inputtext != tmp) {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)