-1

I'm Inserting data using method post to MySql database, but I don't want to insert duplicated data in this database.

I used this:

$insertar="INSERT INTO datos(`nombre`, `cedula`, `Correo`, `telefono`, `ptd`) 
VALUES ('".$_POST['Nombre']."','".$_POST['Identificacion']."','".$_POST['Email']."','".$_POST['Telefono']."','".$_POST['ptd']."')ON DUPLICATE KEY UPDATE nombre=nombre AND cedula=cedula AND Correo=Correo AND telefono=telefono and ptd=ptd;";

$resultado=mysqli_query($conexion,$insertar) or die ('Error en el query database- insertar datos');

but it gives me this mistake:

This is

I need: if the value already is in the database do nothing and continue normally.

ucMedia
  • 4,105
  • 4
  • 38
  • 46

1 Answers1

0

use INSERT IGNORE INTO instead of ON DUPLICATE KEY UPDATE

Luke Luo
  • 14
  • 3