Yiselita

PHP 1

Jan 10th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <pre>
  2. <?php
  3. $host = "winsql.vereb.dc";
  4. $user = "diak64";
  5. $pw = "Jo1Jtn";
  6. $db = "diak64";
  7.  
  8. try{
  9.     $pdo = new PDO("mysql:host={$host};dbname={$db}",$user,$pw);
  10.     echo "CONN SUCC\n";
  11. }
  12. catch(PDOException $e){
  13.     die($e->getMessage());
  14. }
  15.  
  16.  
  17. try{
  18.     $exe = $pdo->prepare("SELECT * FROM nums");
  19.  
  20.     if(!$exe->execute()){
  21.         throw new PDOException ($exe->errorinfo()[2]);
  22.     }
  23.     else{
  24.         print_r($exe->fetchAll());
  25.     }
  26.  
  27.     $exe = $pdo->prepare("INSERT INTO `nums` (`num`,`char`) VALUES (6699,'F')");
  28.  
  29.     if(!$exe->execute()){
  30.         throw new PDOException ($exe->errorinfo()[2]);
  31.     }
  32.  
  33.    
  34.     $exe = $pdo->prepare("SELECT * FROM nums");
  35.  
  36.     if(!$exe->execute()){
  37.         throw new PDOException ($exe->errorinfo()[2]);
  38.     }
  39.     else{
  40.         print_r($exe->fetchAll());
  41.     }
  42.  
  43.  
  44.    
  45.  
  46.  
  47. }
  48. catch(PDOException $e){
  49.     print $e->getMessage();
  50. }
  51. ?>
  52. </pre>
Advertisement
Add Comment
Please, Sign In to add comment