daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Apr 27th, 2016 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TWO CLASSES
  2. class USER
  3. {
  4.     private $db;
  5.  
  6.     function __construct($DB_con)
  7.     {
  8.       $this->db = $DB_con;
  9.     }
  10.  
  11. class FORUM {
  12.  
  13.     function __construct($DB_con)
  14.     {
  15.       $this->db = $DB_con;
  16.     }
  17.  
  18.     public function getSubject() {
  19.         $table = "";
  20.         try {
  21.         $query = $this->db->prepare("DESCRIBE posts");
  22.         $query->execute();
  23.         $forumrow = $query->fetchall(PDO::FETCH_COLUMN);
  24.         print_r($forumrow);
  25.         } catch(PDOException $e) {
  26.             echo $e->getMessage();
  27.         }
  28.     }
  29. }
  30.  
  31. $forum = new FORUM($DB_con);
  32. $forum->getSubject();
  33.  
  34. I have a database conntection too.
  35.  
  36. session_start();
  37.  
  38. $DB_host = "localhost";
  39. $DB_user = "root";
  40. $DB_pass = "";
  41. $DB_name = "dblogin";
  42.  
  43. try
  44. {
  45.      $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
  46.      $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  47. }
  48. catch(PDOException $e)
  49. {
  50.      echo $e->getMessage();
  51. }
  52.  
  53.  
  54. include_once 'users.php';
  55. $user = new USER($DB_con);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top