Jump to content

Recommended Posts

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(); 

?>

Link to comment
https://forums.phpfreaks.com/topic/266245-cant-connect-varlibmysqlmysqlsock/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.