Jump to content

russellharrower

Member
  • Posts

    11
  • Joined

  • Last visited

russellharrower's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I am getting an error, and i am unsure what i have done wrong. LIVE demo - http://www.designvisa.com/beta/include/dbconnect/opendb.php $vconfig = new VConfig(); //Create objects from DBObject class. $myObj = new DBConnect("localhost","$vconfig->user","$vconfig->dbpass","$vconfig->db"); //Call methods of objects. $myObj ->connectToMySQL(); $myObj2 = new DBData(); $myObj2 ->selectDB(); $myObj2 ->showMessage(); class DBConnect{ ///////////////////////////////////////////////// // PRIVATE PROPERTIES ///////////////////////////////////////////////// private $hostname, $username, $password, $db_name, $con; /** * Constructor * @param String $hostname,$username,$password,$db_name. * All information we need to provide whenever connect to db. */ public function __construct($hostname,$username,$password,$db_name){ $this->hostname = $hostname; $this->username = $username; $this->password = $password; $this->db_name = $db_name; } /** * Connect to MySQL. * @return void */ public function connectToMySQL(){ $this->con = mysql_connect($this->hostname,$this->username,$this->password); if($this->con){ echo " Connected sucessfully to MySQL . "; } else{ die( " Could not connect to MySQL" . mysql_error() . ". "); } } } class DBData extends DBConnect{ public function selectDB(){ $result = mysql_select_db($this->db_name,$this->con); if($result){ echo " Connected sucessfully to database ' ".$this->db_name." ' . "; } else{ die( " Could not connect to database ' ". $this->db_name. " ' ".mysql_error() . ". "); } } } class DBClose extends DBConnect{ function closeConnection(){ //Do something else here and at the end you can mysql_close();//For example } } Can anyone help!
  2. Just another question, and an objectName a class name? $DBConnect.closeConnection(); Would something like this work? class DBConnect{ ///////////////////////////////////////////////// // PRIVATE PROPERTIES ///////////////////////////////////////////////// private $hostname, $username, $password, $db_name, $con; /** * Constructor * @param String $hostname,$username,$password,$db_name. * All information we need to provide whenever connect to db. */ public function __construct($hostname,$username,$password,$db_name){ $this->hostname = $hostname; $this->username = $username; $this->password = $password; $this->db_name = $db_name; } /** * Connect to MySQL. * @return void */ public function connectToMySQL(){ $this->con = mysql_connect($this->hostname,$this->username,$this->password); if($this->con){ echo " Connected sucessfully to MySQL . "; } else{ die( " Could not connect to MySQL" . mysql_error() . ". "); } } } class dbclose extends DBConnect{ function closeConnection(){ //Do something else here and at the end you can mysql_close();//For example } }
  3. Thanks Quyen, Just wondering the following: Say i want to have one file that handles connecting to the database. - opendb.php and one that closes the database - closedb.php is that possible, and how? Then say i want another a page to handle MYSQL. - fruitdb.php How would one go about that?
  4. hi Quyen, I get what you are doing, but just one last question if you can help that would be great. how to i fetch data from the database using oops? like say i need to show the table called "yum" inside the table "yum" it has two rows with data, under the row called "fruit" 1 - apple 2 - banana But i when i run the select fruit from yum; it prints both of the fruit - "applebanana" what i need it to do is give each fruit a class or a way i can call it by $class->fruitone; $class->fruittwo; Can you help there?
  5. hi Quyen, That would be GREAT if you would share, I am starting to get the hang of it i think, i am understanding things a bit better. If you can share that would be GREAT and i thank you from the bottom of my heart. Thanks
  6. Hi guys, I have looked everywhere with NO success, I don't understand any of these frameworks that are already out, and i have read all the killerphp.com documents and watch all the videos that i can find about OOP and still cant find what i need. I am new to OOP but know PHP, if someone can PLEASE help me out, and show me an example on how to use OOP to connect to MySQL that would be GREAT! PLEASE HELP Thanks
  7. Sorry?? i am not understanding what you are talking about...
  8. why not just have one row for keywords and separate each keyword with a , if you look into a cms database like wordpress, joomla etc. you will see this is how they do it (off the top of my head) I know this is how i did it for a client.
  9. Oh also i forgot to let you know, it can also play videos, something your church may want to do later down the road. There is a wizard that will show you how to get the player to work on your site including the html code. Also it works on all computers and in all browsers because it is flash.
  10. Can i suggest that you use something like JW flash player, its a free Flash player, that will allow users to click play and it will play the mp3 or any file that you want. You can however also make it fetch the audio file from a mysql database, or any database, this way you dont have to make a xml file, or even a page for each audio file.
  11. Hi, i like your script, i have been having issues connecting with the DB using OOPS however i seem to get a blank page when i use your script. I understand why i am getting a blank page, due to i have not called the class, but when i try to call the class i can't. I was wondering if you would kindly show us, how you would call the viewResult... Thanks Russell H.
×
×
  • Create New...