如何使用$ _get VARIABLE IN WHERE Close使用Php Mysql更新表

I have been trying to create an edit link for my web application. the update request doesn't work and oddly I am not getting any error. any ideas please .Thanks in advance

Here is my code:

<?php

$id=$_GET["invistID"];

if(isset($_POST['validation']))// the submit buttom
{
 try
 {
  $req = $bdd->prepare('UPDATE invistigation_en SET     fininvist=:fininvist,rapportinvist=:rapportinvist,status=:status WHERE  invistID=:invistID');

$data =array(
':invistID'=>$id,
':fininvist'=> $_POST['fin'],
':rapportinvist'=> $_POST['rapport'],
':status'=> $_POST['status']

);
$req->execute($data);
echo "success ...";
 }catch(PDOException $e){
 echo "Error ... :".$e->getMessage();
   }

header('Location:invistigation.php');// 

}
?>

Debug is an important step when you build applications. When you write code, some times, application behavior is not as you expects. This is your case. At this time, you should isolate your issue and fix it.

To isolate issue they are some techniques. At this time you don't know why this code don't run. Then you should identify program check points and check if, at this points, all is as you expect.

For your code:

  1. Check all page parameters have expected values. var_dump( $_POST )
  2. Check all query parameters you send to execute are right: var_dump( $data )
  3. Print errors as @andrewsi suggest: var_dump($bdd->ErrorInfo()) var_dump($req->ErrorInfo()) .
  4. If problem persist raise your own errors: change Update word by XXXX, execute and check if some errors appear.
  5. Remove redirect ( header('Location ... ), change it by die("end") to see all page errors.

good luck, and please, let us know, finally, where your error was.