Mysql problem
#1

This wont write to the table nothin appear on the table, why?
pawn Код:
if(dialogid == Registerdialog)
    {
        new password[64],string[200];
        format(password,sizeof(password),"%s",inputtext);
        format(string,sizeof(string),""lred"Must be more than 3 letters\n"lgreen"Welcome "lblue"%s \n"lyellow"We see you want to register on our "lred"server! \n"lyellow"Type in a password to "lred"register",GetPName(playerid));
        if(strlen(password) < 3) return ShowPlayerDialog(playerid,Registerdialog,1,""lred"Register",string,"Register","Cancel");
        format(Query,sizeof(Query),"INSET INTO `Users` (`Username`, `Password`) VALUES ('%s','%s')",GetPName(playerid),password);
        mysql_query(Query);
        mysql_query("SELECT * FROM `Users`");
        mysql_store_result();
        format(string,sizeof(string),"||- "lgreen"%s "lyellow"has "lred"registered "lyellow"on our server, now we have "lpink"%i "lyellow"registered users! "lred"-||",GetPName(playerid),mysql_num_rows());
        SendClientMessageToAll(red,string);
        mysql_free_result();
    }
Reply
#2

Quote:
Originally Posted by Carrot
Посмотреть сообщение
This wont write to the table nothin appear on the table, why?
pawn Код:
if(dialogid == Registerdialog)
    {
        new password[64],string[200];
        format(password,sizeof(password),"%s",inputtext);
        format(string,sizeof(string),""lred"Must be more than 3 letters\n"lgreen"Welcome "lblue"%s \n"lyellow"We see you want to register on our "lred"server! \n"lyellow"Type in a password to "lred"register",GetPName(playerid));
        if(strlen(password) < 3) return ShowPlayerDialog(playerid,Registerdialog,1,""lred"Register",string,"Register","Cancel");
        format(Query,sizeof(Query),"INSET INTO `Users` (`Username`, `Password`) VALUES ('%s','%s')",GetPName(playerid),password);
        mysql_query(Query);
        mysql_query("SELECT * FROM `Users`");
        mysql_store_result();
        format(string,sizeof(string),"||- "lgreen"%s "lyellow"has "lred"registered "lyellow"on our server, now we have "lpink"%i "lyellow"registered users! "lred"-||",GetPName(playerid),mysql_num_rows());
        SendClientMessageToAll(red,string);
        mysql_free_result();
    }
Should be INSERT INTO
Reply
#3

Next time if you need help try using
Код:
mysql_debug( 1 );
and sometimes you can check the error log and fix it by yourself.
Reply
#4

You should also probably note that this snippet of code is vulnerable to an SQL injection attack, you should look into using the mysql_real_escape_string function to protect your server from such attacks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)