Jump to content
  • 0

NPC don't insert words


Westin

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   1
  • Joined:  10/25/12
  • Last Seen:  

Hi, in "insira seu nome" only register numbers, if try any letters return this error:

 

ERROR:

 
	: DB error - Unknown column 'Jose' in 'field list'
	    [Debug]: at script.cpp:17079 - UPDATE login SET nome = Jose WHERE account_id = 2000100

Quote

 

CODE:

 

        mes .@n$;
        mes "Insira seu nome";
        input(.@nome$);    
        query_sql("UPDATE login SET nome = "+ .@nome$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes .@n$;
        mes "Insira seu CPF";
        input .@cpf$;
        query_sql("UPDATE login SET cpf = "+ .@cpf$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes .@n$;
        mes "Insira sua chave";
        input .@chave$;
        query_sql("UPDATE login SET chave= "+ .@chave$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes .@n$;
        mes "Cadastro realizado com ^008000sucesso.^000000";
        close;

 

 

Why i m wrong?

Edited by holdur
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

use apostrophe to envelope the string, else the SQL engine treat it as column name instead of text.

query_sql("UPDATE login SET nome = '"+escape_sql(.@nome$)+"' WHERE account_id = "+ getcharid(3));
query_sql("UPDATE login SET cpf = '"+escape_sql(.@cpf$)+"' WHERE account_id = "+ getcharid(3));
query_sql("UPDATE login SET chave= '"+escape_sql(.@chave$)+"' WHERE account_id = "+ getcharid(3));

and all string that insert into SQL database should use escape_sql(...) to escape any special characters

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...