Syntax error when updating data in MySQL

0

I'm trying to update a user's data in mysql. Someone can identify me why I get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'dip=133.421, nombre=Antonio, apellidos=Bielo Lopez WHERE id=1' at line 1

This is my query:

$insertar="UPDATE usuarios SET  dip='".$dip0."', nombre='".$nombre0."', apellidos='".$apellidos0."', sexo='".$genero0."', telefono='".$telefono0."', correo='".$correo0."', username='".$username0."' WHERE id='".$id0."'";

If you need more information to identify the problem, please tell me, please.

    
asked by Tony_Bielo 30.11.2018 в 11:04
source

3 answers

1

You are probably using the quotes in numeric fields (int, float, etc), if so, in these fields remove the single quotes.

    
answered by 30.11.2018 в 11:52
0

The error is that neither name nor surname has quotes.

Certainly the query that you put quotes in the fields, but something you do with the data because the error is clear:

  

You have an error in your SQL syntax; check the manual that   corresponds to your MariaDB server version for the right syntax to use   near 'dip = 133.421, name = Antonio , last name = Bielo Lopez WHERE id = 1'   at line 1

(edit)

In case there are doubts, in case of not putting quotation marks the error is of syntax not of Unknow colum :

and with quotes:

    
answered by 30.11.2018 в 11:41
0

I had some extra quotes in some variables:

No

$nombre0=$_POST["nombre0'"]; 

Yes

$nombre0=$_POST["nombre0"];

I guess it was the problem. I dont know. I deleted all my code and started over again

    
answered by 30.11.2018 в 12:53