1

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 :

https://stackoverflow.com/questions/24400675/how-to-delete-a-record-in-php-that-has-composite-multi-column-primary-key

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 ^

`

  • Is MySQL the DBMS? Or something else? And which version? – ypercubeᵀᴹ Jul 10 '17 at 04:54
  • It's usually helpful to print the actual SQL that is producing the error message. You are probably sending a query with an empty id_valor. Something like WHERE ... AND id_valor = LIMIT 1 would produce this error message – ypercubeᵀᴹ Jul 10 '17 at 08:29
  • So, at this point, the SQL statement shown in your code doesn't match the error message you're getting. We might be able to help more if we saw the code that's actually generating the stated error. If you have a literal ^ character in your SQL statement, that would definitely be a problem. – RDFozz Jul 10 '17 at 15:58

0 Answers0