The Little Guy Posted May 12, 2009 Share Posted May 12, 2009 First off... I can't find the OOP board, has it been removed? Next... I have been experimenting with OOP, and I have run into some issues, that hopefully you guys can help me with. I am getting these error messages: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/ryannaddy/biz.gmserver.net/incl/Classes/News.php on line 7 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/ryannaddy/biz.gmserver.net/incl/Classes/News.php on line 7 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ryannaddy/biz.gmserver.net/incl/Classes/News.php on line 7 I am using two classes class MySQL: <?php class MySQL{ public function __construct(){ $dbHost = "mysql.phpsnips.com"; $dbUser = "user"; $dbPass = "pass"; $dbDatabase = "bizsim"; $db = mysql_connect($dbHost, $dbUser, $dbPass) or die ("Error connecting to database."); mysql_select_db($dbDatabase, $db) or die ("Couldn't select the database."); } } ?> and class News: <?php class News extends MySQL{ public function __construct(){ } public function get_news($dir = 'ASC', $count = 3){ return mysql_fetch_array(mysql_query("SELECT * FROM news LIMIT $count $dir")); } } ?> then on the page I use it, I do this: <?php $news = new News(); $news->get_news(); ?> What is the problem? I am using the Class auto loader btw. Link to comment https://forums.phpfreaks.com/topic/157884-solved-oop-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.