Jump to content
  • 0

NPC don't insert words


Question

Posted (edited)

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

1 answer to this question

Recommended Posts

  • 0
Posted

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...