I am trying to delete a row from a table using two conditions. this is my code :
<?php require 'database.php'; $id=0;$od=0; if(!empty($_GET['id_espece'])){ $id=$_REQUEST['id_espece']; }if(!empty($_GET['id_valor'])){ $od=$_REQUEST['id_valor']; } if(!empty($_POST)){ $id= $_POST['id_espece'];$od= $_POST ['id_valor']; $pdo=Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'DELETE FROM mode_valorisation WHERE "id_espece" = ? and "id_valor" = ? ';
$q = $pdo->prepare($sql);
$q->execute(array($id,$od));
Database::disconnect();
header("Location: page-valo.php");
}
?>
<form class="form-horizontal" action="page-supprimervalo.php" method="post" style="background: #89e29a; border-color: black; border-radius: 20px; padding: 5px;width: 500px; position: relative;right: -480px;" >
<input type="hidden" name="id_espece" value="<?php echo $id;?>"/>
<input type="hidden" name="id_valor" value="<?php echo $od;?>"/>
</form>
I Tried the solution proposed here :
but it gives me the following error : `
syntax error at or near "limit" LINE 1: ..._valorisation WHERE id_espece = $1 and id_valor = $2 limit 1 ^
`
id_valor. Something likeWHERE ... AND id_valor = LIMIT 1would produce this error message – ypercubeᵀᴹ Jul 10 '17 at 08:29^character in your SQL statement, that would definitely be a problem. – RDFozz Jul 10 '17 at 15:58