asucrews Posted December 27, 2008 Share Posted December 27, 2008 okay so were did i go worng? i am getting this error... "mysqli_query() expects parameter 1 to be mysqli, null given in test.php on line 9" Test.php <?php require("database.inc"); $database = new MySQLDB(); $compnayid = 1; $sql = "SELECT * FROM `studios` WHERE `companyID` = $companyid"; $result = mysqli_query($database->MySQLDB(),$sql); echo $result; ?> database.inc <?php require("constants.inc"); class MySQLDB{ public $connection; public function showerror() { if (mysqli_connect_error()){ die ("Error". mysqli_connect_errno() . " : " . mysqli_connect_error()); }else{ die ("Could not connect to the MySQL Database"); } } public function MySQLDB() { $this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS) or self::showerror(); mysqli_select_db($this->connection, DB_NAME) or self::showerror(); } } ?> Link to comment https://forums.phpfreaks.com/topic/138555-mysqli-and-simple-class/ Share on other sites More sharing options...
premiso Posted December 27, 2008 Share Posted December 27, 2008 $result = mysqli_query($database->connection,$sql); Link to comment https://forums.phpfreaks.com/topic/138555-mysqli-and-simple-class/#findComment-724450 Share on other sites More sharing options...
asucrews Posted December 27, 2008 Author Share Posted December 27, 2008 wow!!!! why does it seem to me the simple things that get me all that time ??? THANKS!!!!! Link to comment https://forums.phpfreaks.com/topic/138555-mysqli-and-simple-class/#findComment-724453 Share on other sites More sharing options...
premiso Posted December 27, 2008 Share Posted December 27, 2008 wow!!!! why does it seem to me the simple things that get me all that time ??? THANKS!!!!! It's not just you trust me. I could spend hours looking at my own code and miss something that small and I should have caught in the first 5 seconds of looking at it. That is just how your mind works. Sometimes printing the problem code on paper helps too. Link to comment https://forums.phpfreaks.com/topic/138555-mysqli-and-simple-class/#findComment-724456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.