×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Francesco St
Added: Jul 14, 2016 3:05 PM
Views: 10
create code to return data from DB
  1. include("../dba/dba.php");
  2. $dbaobj = new dba;
  3.  
  4. $usr = $dbaobj->getUsr();
  5.  
  6. $pwd = $dbaobj->getPwd();
  7.  
  8.  
  9. try{              
  10. $pdo = new PDO("mysql:host=mysql.hostinger.it;dbname=u730190353_gerks", $usr, $pwd);
  11.     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.    
  13.    
  14.    
  15. $params = array();
  16.  
  17. $stmt = $pdo->prepare($prepquery);
  18.      
  19.  
  20. $stmt->execute($params);
  21.  
  22. $result = $stmt->fetchAll();
  23. }
  24. catch(PDOException $e)
  25.     {
  26.     echo 'ERROR: ' . $e->getMessage();
  27.     }