Query not working
#1

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?
Reply
#2

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`
Reply
#3

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
Reply
#4

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
Reply
#5

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.
Reply
#6

Worked thx!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)