mysql_connect() problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jlackyashdya
Forum Newbie
Posts: 2
Joined: Fri Nov 13, 2009 3:24 am

mysql_connect() problem

Post by jlackyashdya »

hi,

i m new to php- mysql .

i have write simple code for making connection to the databse :
<?php
$link = mysql_connect('localhost', 'abc', 'abc123'); // (which is databse username and password)
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

but its giving me following warning...
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /misc/34/000/110/762/7/user/web/rollball.org/test.php on line 4
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

please help me...

Thanks a lot
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: mysql_connect() problem

Post by onion2k »

MySQL isn't running (or it's on a port that isn't standard). Talk to your hosting company.
jlackyashdya
Forum Newbie
Posts: 2
Joined: Fri Nov 13, 2009 3:24 am

Re: mysql_connect() problem

Post by jlackyashdya »

Thanks :)
Post Reply