fork download
  1. <?php
  2.  
  3. // your code goes here
  4. function update($data,$where)
  5. {
  6. try {
  7. $dns ="mysql:dbname=students;host=127.0.0.1;port=3306;";
  8. $usre="root";
  9. $password ="";
  10.  
  11. $db =new PDO($dns, $usre, $password);
  12.  
  13. $query = "UPDATE `student' SET $data WHERE $where";
  14. // print($query);
  15. $stmt=$db->prepare($query);
  16. // $stmt->bindParam(":x", $us, PDO::PARAM_STR);
  17.  
  18. $stmt->execute();
  19. echo $stmt->rowCount();
  20. if($stmt->rowCount()>0)
  21. {return 'updated';}
  22. else
  23. return 'unupdated';
  24.  
  25. } catch(PDOException $e) {
  26. echo "Error: " . $e->getMessage();
  27. return null;
  28. }
  29. }
Success #stdin #stdout 0.03s 25544KB
stdin
Standard input is empty
stdout
Standard output is empty