Posted By

LuckyShot on 05/12/10


Tagged

mysql database php connection


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

digitalbart
wesleymacente
dantreacy
eval
joacoleo
pixelsoul
dilios


PHP/MySQL - Database Class


 / Published in: PHP
 

URL: http://xaviesteve.com/category/web-design/mysql/

  1. class MySQLDB
  2. {
  3. /* Class constructor */
  4. function MySQLDB(){
  5. $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
  6. mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
  7. }
  8.  
  9. function query($query){
  10. return mysql_query($query, $this->connection);
  11. }
  12. };
  13.  
  14. $database = new MySQLDB;
  15.  
  16.  
  17.  
  18.  
  19. $result = $database->query($query);
  20. $num_rows = mysql_num_rows($result);
  21.  
  22.  
  23. $post_title = mysql_result($result,0,"title");

Report this snippet   <

You need to login to post a comment.