It is currently Wed Jan 17, 2018 11:05 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Warning: mysql_connect() HELP!!
PostPosted: Tue Nov 28, 2006 3:35 pm 
Noobie
Noobie

Joined: Tue Nov 28, 2006 3:29 pm
Posts: 1
Hi, I'm trying to use a php script to connect to my database, but I keep getting the following error:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/garpoo.100webspace.net/inc/config.inc.php on line 2117
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

btw, here is the code in my script:

function db_open ()
{
global $settings;
if (!($dbconn = mysql_connect ($settings['mysql1.100ws.com:3306'], $settings['garpoo_test'], $settings['*****'])))
{
exit (mysql_error ());
;
}

if (!mysql_select_db ($settings['garpoo_test']))
{
print mysql_error ();
exit ();
}

return $dbconn;
}

function db_close ($dbconn)
{
mysql_close ($dbconn);
}


Parameters for hostname, login, and password should be all correct. What do I need to do to get this working? Do I need to have a mysql.sock file? I am still very new to database management. Any help would be appreciated. Thanks a bunch! :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2008 1:21 am 
Experienced
Experienced

Joined: Fri May 13, 2005 10:24 am
Posts: 54
I'm a little confused with what you are doing here, normally when storing data to a variable it's usage would be something like:
Code:
$settings = array(
  'host'=>'mysql1.100ws.com:3306',
  'username'=>'garpoo_test',
  'password'=>'******'
);

function db_open(){
  global $settings;
  if(!($dbconn = mysql_connect ($settings['host'], $settings['username'], $settings['password']))){
      die(mysql_error ());
  }
....


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011