barrylee Posted September 20, 2008 Share Posted September 20, 2008 Can anyone help, I am about to write a new php system but wish to use the mysqli class, I have done it once before but have since lost the code and can't rember how I did it. I have found some tutorials bu they all seem to have the mysqli function in the same page as their code. I will probably use about 8-10 class files so only want to use mysqli once then extend the other classes off that. Trouble is that the sub classes cannot seem to inherit the mysqli object, I know I have got it working once before but cannot get it right this time, here is a small example of what I'm trying to do. <?php @ $db = new mysqli($host, 'root', '', 'NewPhatBass'); if(mysqli_connect_errno()) { echo 'ERROR: Unable to connect to database at this time.'; exit; } return $db; ?> function Nav(){ $db = parent::db(); $result = $db->query("SELECT title FROM cats"); while( $row = $result->fetch_assoc() ) I hope this snippet will give someone an idea of what I am trying to acheive, thanks in advance to anyone who can help. Link to comment https://forums.phpfreaks.com/topic/125085-help-with-mysqli/ Share on other sites More sharing options...
barrylee Posted September 20, 2008 Author Share Posted September 20, 2008 thanks but don't worry, I have fixed it! Link to comment https://forums.phpfreaks.com/topic/125085-help-with-mysqli/#findComment-646470 Share on other sites More sharing options...
barrylee Posted September 20, 2008 Author Share Posted September 20, 2008 just in case anyone wants to know it was like this <?php class Conn { function Conn(){ @ $db = new mysqli($host, 'root', '', 'NewPhatBass'); return $db; } } ?> my other classes then go function Nav(){ $db = parent::Conn(); $result = $db->query("SELECT title FROM cats"); etc. Link to comment https://forums.phpfreaks.com/topic/125085-help-with-mysqli/#findComment-646476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.