Jump to content
  • 0
holdur

NPC don't insert words

Question

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 [email protected]$;
        mes "Insira seu nome";
        input([email protected]$);    
        query_sql("UPDATE login SET nome = "+ [email protected]$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes [email protected]$;
        mes "Insira seu CPF";
        input [email protected]$;
        query_sql("UPDATE login SET cpf = "+ [email protected]$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes [email protected]$;
        mes "Insira sua chave";
        input [email protected]$;
        query_sql("UPDATE login SET chave= "+ [email protected]$ +" WHERE account_id = "+ getcharid(3));
        next;
        mes [email protected]$;
        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

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([email protected]$)+"' WHERE account_id = "+ getcharid(3));
query_sql("UPDATE login SET cpf = '"+escape_sql([email protected]$)+"' WHERE account_id = "+ getcharid(3));
query_sql("UPDATE login SET chave= '"+escape_sql([email protected]$)+"' 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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.