SA-MP Forums Archive
Mysql problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql problem (/showthread.php?tid=248028)



Mysql problem - Carrot - 11.04.2011

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();
    }



Re: Mysql problem - Mokerr - 11.04.2011

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


Re: Mysql problem - Retardedwolf - 11.04.2011

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


Re: Mysql problem - JaTochNietDan - 11.04.2011

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.