Advertisement
cuonic

Untitled

Jul 6th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. class cms
  4. {
  5.     private $mysqli;
  6.  
  7.         function __construct()
  8.         {
  9.                 $this->mysqli = new mysqli("127.0.0.1", "cms", "testuser", "cms", 3306);
  10.                 if ($this->mysqli->connect_errno)
  11.         {
  12.                     echo "Failed to connect to MySQL: (" . $this->mysqli->connect_errno . ") " . $this->mysqli->connect_error;
  13.         }
  14.         }
  15.  
  16.         function title($pagename)
  17.     {
  18.         $query = $this->mysqli->prepare("SELECT title FROM pages WHERE pagename=?");
  19.         $query->bind_param("s", $pagetitle);
  20.         $query->bind_result($title);
  21.         $query->execute();
  22.         $query->fetch();
  23.         $query->close();
  24.        
  25.         echo $title;
  26.     }
  27.  
  28.         function content($pagename)
  29.     {
  30.         $query = $this->mysqli->prepare("SELECT content FROM pages WHERE pagename=?");
  31.         $query->bind_param("s", $pagetitle);
  32.         $query->bind_result($content);
  33.         $query->execute();
  34.         $query->fetch();
  35.         $query->close();
  36.  
  37.         echo $content;
  38.     }
  39. }
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement