SQL Problem.
#1

PHP код:
CMD:notice(playeridparams[])
{
    if(
isnull(params))
    {
        return 
SendClientMessage(playeridCOLOR_GREY"/notice [text]")
    }
    if(
pInfo[playerid][pNotice] == 1)
    {
        return 
SendClientMessage(playeridCOLOR_GREY"You've used your notice. Type /deletenotice to delete it.")
    }
    else
    {
        
pInfo[playerid][pNotice] = 1;
        new 
string[127];
        
format(stringsizeof(string), "You've set your notice to %s"params)
        
SendClientMessage(playeridCOLOR_WHITEstring)
        
mysql_format(db_infoquerysizeof(query), "UPDATE players SET noticetext = %s WHERE pid = %i"paramsGetPlayerDBId(playerid)); 
        
mysql_tquery(db_infoquery"""");
    }
return 
1;

Now if i try it in game it says
PHP код:
DescriptionUnknown column 'Test' in 'field list' (index 0). Query// TEST is the params the player putted at /notice
[22:58:47UPDATE players SET noticetext Test WHERE pid 
What's the problem :/?
Reply
#2

Well, it says the error. You may have used the output you got from /notice incorrectly (if you have just made this command and DB entry)

I'd suggest trying to re-import the sql if you are on a test box, but if this is a live server be very careful and simply make the field that it's missing.


When did it start happening, and what were you doing when it started.
Reply
#3

Код:
mysql_format(db_info, query, sizeof(query), "UPDATE players SET noticetext = '%e' WHERE pid = %i", params, GetPlayerDBId(playerid));
you have to enclose string with ' or "
and also, use %e instead of %s if the string can be inputted by player to escape string
Reply
#4

Код:
UPDATE players SET noticetext = %s WHERE pid = %i
I simply tested the command in game, so i did /notice test and it gave me that error, the field exists in table structure, i dont know whats wrong with it..
Reply
#5

Quote:
Originally Posted by X337
Посмотреть сообщение
Код:
mysql_format(db_info, query, sizeof(query), "UPDATE players SET noticetext = '%e' WHERE pid = %i", params, GetPlayerDBId(playerid));
you have to enclose string with ' or "
and also, use %e instead of %s if the string can be inputted by player to escape string
Worked, thanks a lot. I thought about this but never tested, much appreciated.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)