I have to change the value / state to an ENUM ('0', '1') of a field in a table. I'll do it with an UPDATE query with if included.
cambiar_estado.php:
<?php
//Dormimos el proceso unos segundos...
sleep(3);
//Consulta para actualizar el estado en la tabla "usuarios_datos".
$Sql = "UPDATE usuarios_datos if(estado = '0', SET estado = '1'), if(estado = '1', SET estado = '0') WHERE ID_OBLIGATORIO = '$_REQUEST["Id"];";
?>
<center>
<?php
echo "<a href=\"javascript:cargaXML('cambiar_estado.php?Id=".$_REQUEST["Id"]."','estado".$_REQUEST["Id"]."')\">";
echo $Sql;
echo "</a>";
?>
</center>
Error # 1064 - 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 'if state = 0 SET state = 1 else if state = 1 SET e' at line 1