Howlin1 Posted December 19, 2011 Share Posted December 19, 2011 When I try print some news stories to my homepage I get the following error: SELECT Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) The code that I am using is: <?php require ('news/news.php'); ?> and in the news.php file that code is: <?php include 'inc/connect_db.php'; $result = mysql_query("SELECT * FROM site_news") or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); while ($get_info = mysql_fetch_row($result)) { echo "<td>{$get_info[1]}</td>"; } ?> If I go to the news.php file itself, the code will run and I can see the news story that I have. I have tried using require, require_once, include and include_once but they all come up with the same error. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
premiso Posted December 19, 2011 Share Posted December 19, 2011 Seems like your MySQL server is offline. That or the MySQL connection is never made in your code. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2011 Share Posted December 19, 2011 Probably a path issue with the included file. Set up PHP's error reporting and see if there are related errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.