Field with Cedilla in Mysql

Asked

Viewed 669 times

0

I have a field in my database table Mysql with the name 'description', with the special accents.

My problem is this: When I make a INSERT INTO using directly the phpMyAdmin, it normally inserts the information into the table, but when using the mysql in the application it returns the following error.

erro sql

This is my sql code:

INSERT INTO caixa_geral_dc (
descrição,
empresa,
valor_c_d,
conta,
categoria,
d_c,
usuario)
VALUES 
('GUARDA PROVISÓRIA DE VALORES',
'$nome_cliente[$i]',
'$v_recebido&[$i]',
'7',
'197',
'c',
'$_SERVER[nomeUsuario]')

I await answers.

Thank you

3 answers

3

Enter the name of your field between ` to indicate that it is a field (this is also for restricted and/or spaced names)

INSERT INTO caixa_geral_dc ( `descrição`, empresa, valor_c_d, conta, categoria, d_c, usuario) VALUES ('GUARDA PROVISÓRIA DE VALORES', '$nome_cliente[$i]', '$v_recebido&[$i]', '7', '197', 'c', '$_SERVER[nomeUsuario]')
  • I did what you recommended. Thanks for the help, but it now returns: You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near '[description], ' at line 2

  • @netoweb I’ll take a look and I’ll get back to you

  • Okay. Thanks for your help, buddy

  • Updated, but also sent a new reply

  • For the first time I came across this situation, rsrsrs

  • the name cannot be changed ?

  • I’ll talk to my supervisor about it. Anything I return here

  • Unfortunately it will not be changed for now.

Show 3 more comments

2


When you have a field with special characters or white spaces in it, this field should be declared within ``

Follows how your query should look:

INSERT INTO caixa_geral_dc ( `descrição`, empresa, valor_c_d, conta, categoria, d_c, usuario) VALUES ('GUARDA PROVISÓRIA DE VALORES', '$nome_cliente[$i]', '$v_recebido&[$i]', '7', '197', 'c', '$_SERVER[nomeUsuario]') 
  • Unknown column 'description' in 'field list'

  • This was the result. :\

  • your field is actually written as description in the bank?

  • @netoweb use ` instead of '

  • @netoweb remembering that it is a crase and n a simple quotes

  • Yes yes. I used the crase and still it keeps giving error. Unfortunately the field in the database is description... We are switching from Access to Web.

Show 1 more comment

1

Guys. Thanks for all your help, but I solved my problem. Just add the line

mysql_set_charset('utf8');

in the related.php file to work.

Recalling that also the addition of the crase before description, solved the problem.

Stayed like this:

inserir a descrição da imagem aqui

Thank you very much! See you! D

  • Perfect, this I didn’t know haha

  • kkkk living & learning rsrs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.