turpentyne Posted July 25, 2012 Share Posted July 25, 2012 I'm trying to add a new section to somebody's existing site. I need to connect to the database, and I'm not sure what to do with the error I got: Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/m/c/m/mcmfamily/html/builder-test-code/dbc.php on line 10 Here's what I'm using as my connection: <?php function dbconn() { if(!include_once('../filepath/dbc_include.php')) { die('Error include file...'); } if(!$link = mysql_connect($db['hostname'],$db['username'],$db['password'])) { die('Error connecting...'); } if(!mysql_select_db($db)) { die('Error selecting...'); } return $link; echo @mysql_ping() ? 'true' : 'false'; } $link = dbconn(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266245-cant-connect-varlibmysqlmysqlsock/ Share on other sites More sharing options...
jazzman1 Posted July 25, 2012 Share Posted July 25, 2012 Do you want to connect your local machine to remote database, right ? Quote Link to comment https://forums.phpfreaks.com/topic/266245-cant-connect-varlibmysqlmysqlsock/#findComment-1364360 Share on other sites More sharing options...
jcbones Posted July 25, 2012 Share Posted July 25, 2012 Is this on a local machine, or on a web host? This is basically saying that the server cannot find the mysql socket(file, not port). Either: A. The socket file is in another location. ie /tmp/mysql.socket B. The MySQL installation is hosed. Quote Link to comment https://forums.phpfreaks.com/topic/266245-cant-connect-varlibmysqlmysqlsock/#findComment-1364381 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.