Advertisement
GWibisono

try - catch

Sep 18th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. <?php
  2. //HARUSNYA
  3. $error=null; /*asumsikan WAJIB*/
  4. try{
  5.     $sql = '';
  6.     $query= $con->prepare($sql);
  7.     $query->bindParam(1, $foto);
  8.     $query->bindParam(2, $foto);
  9.     $result = $query->execute();
  10. }
  11. catch(PDOException $e){
  12.     $error= $e->getMessage();
  13.     $result=false;
  14. }
  15.  
  16. if($result){
  17.     //jalankan script OK
  18. }
  19. else{
  20.     die( $error);
  21.    
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement