SA-MP Forums Archive
Query not working - 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: Query not working (/showthread.php?tid=621228)



Query not working - StrikerZ - 08.11.2016

PHP код:
new Query[700];
              
format(Query,sizeof(Query),"INSERT INTO `users` (`Name`, `RegisteredOn`, `RegisteredIP`, `LastLoggedIP`, `Password`, `Level`, `Banned`");
              
format(Query,sizeof(Query),"%s, `Donator`, `Score`, `Cash`, `Kills`, `Deaths`, `Skin`, `Muted`, `Autologin`, `TotalSeconds`,`TotalSpentTime`",Query);
              
format(Query,sizeof(Query),"%s, `LastSeen`) VALUES(`%s`,`%s`, `%s`, `%s`, `%e`, `%d`, `%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%s`,`%s`)",Query,PN(playerid), string,pIP,pIP,buf,0,0,0,1,1500,0,0,0,0,0,seconds,ConvertTime(seconds,mins,hour,day),str);
              
mysql_tquery(MysqlQuery"OnAccountRegister""i"playerid); 
This is not inserting the data. And to confirm if its inserted i used this
PHP код:
forward OnAccountRegister(playerid);
public 
OnAccountRegister(playerid)
{
    
printf("[Registration] New account registered. Database ID: ");
    return 
true;

Which is not even displayed. That means the query is not inserting the data. Any idea why?


Re: Query not working - X337 - 08.11.2016

Use single quotes instead of ticks, on this code:
Код:
`%s`,`%s`, `%s`, `%s`, `%e`, `%d`, `%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%s`,`%s`



Re: Query not working - StrikerZ - 08.11.2016

Quote:
Originally Posted by X337
Посмотреть сообщение
Use single quotes instead of ticks, on this code:
Код:
`%s`,`%s`, `%s`, `%s`, `%e`, `%d`, `%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%s`,`%s`
What do you mean? Please elaborate more


Re: Query not working - StrikerZ - 08.11.2016

Opened debug and it returned these errors
PHP код:
[15:57:23] [ERRORCMySQLQuery::Execute[OnAccountRegister(i)] - (error #1054) Unknown column 'Matteo' in 'field list'
[15:57:27] [ERRORCMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `Name` = `Matteo`' at line 1 
It's not saving my name


Re: Query not working - X337 - 08.11.2016

Replace this code:
Код:
format(Query,sizeof(Query),"%s, `LastSeen`) VALUES(`%s`,`%s`, `%s`, `%s`, `%e`, `%d`, `%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%s`,`%s`)",Query,PN(playerid), string,pIP,pIP,buf,0,0,0,1,1500,0,0,0,0,0,seconds,ConvertTime(seconds,mins,hour,day),str,PN(playerid));
with this:
Код:
format(Query,sizeof(Query),"%s, `LastSeen`) VALUES('%s','%s', '%s', '%s', '%e', '%d', '%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%s','%s')",Query,PN(playerid), string,pIP,pIP,buf,0,0,0,1,1500,0,0,0,0,0,seconds,ConvertTime(seconds,mins,hour,day),str,PN(playerid));
Use ' instead of `. otherwise, those values will be treated as tables.


Re: Query not working - StrikerZ - 08.11.2016

Worked thx!