Current location: Hot Scripts Forums » Programming Languages » PHP » Mysql_connect class


Mysql_connect class

Reply
  #1 (permalink)  
Old 05-11-04, 12:26 PM
Merovingian's Avatar
Merovingian Merovingian is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Los Angeles
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Mysql_connect class

Hey!
In an attempt to get more worked done I have decided to make custom mysql_connect classes using PHP:
But the problem I am facing is how to use the class and actually get data from the database using the class in an index.php page.I am stumped if you guys have any clue on how to do it correctly since all I have been getting is errors please reply to this Post.
My code is the following form my file "db.class.php":
PHP Code:

<?php

//Class Definitions.
class db{
    function 
dbConn(){
        if(!
$link = @mysql_connection(dbHost,dbUsr,dbPass)){
            die (
"MYSQL_ERROR:".mysql_error());
        }else{
            if(!@
mysql_db_select(dbSelect)){
                die (
"MYSQL_DB_SELECT ERROR:".mysql_error());
            }else{
            return 
$link;
            }
        }
    }
//Do queries.
    
function query($dbsql){
        
$link $this->dbConn();
        if(!
$qdb = @mysql_query($dbsql)){
            die (
mysql_error()."<br />".$dbsql);
        }
    }
//Select item from DB.
    
function dbItem($dbsql){
        
$link $this->dbConn();
        if(!
$item = @mysql_query($dbsql)){
            die(
mysql_error()."<br />".$dbsql);
        }else{
            
$iRows mysql_fetch_array($item);
            
$reveal $irow['username'];
            
mysql_close($link);
            return 
$reveal;
        }
    }
                
}
?>
If theres a better way of doing this and getting better results to be viewed please post how to it would relieve my stress !
//Merovingian.
__________________
"Duo seguere aut de via decede" ...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a class illogix ASP.NET 1 03-13-04 11:25 PM
Rec of HTML Table generating class krose PHP 0 02-15-04 11:21 AM
looking for class registration script KingSky PHP 4 06-27-03 01:44 PM


All times are GMT -5. The time now is 10:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.