Jump to content

Recommended Posts

Hi all,
i really aint got a clue what is going on, i have used this code a hundred times before but i don't think it likes my new host.

[a href=\"http://aaron.awardspace.co.uk/home.php\" target=\"_blank\"]an example is here [/a]

i get this error message everything time:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/aaron.awardspace.co.uk/db_connect.php on line 10
Couldn't connect to server.[/quote]


and here is my simple to use code:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?
//mysql
$host = "localhost";
$username = "username";
$password = "password";
$database_name = "tkd1987_aaron";

//databsae connection.

$connection = mysql_pconnect("$host","$username","$password")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>[/quote]

Sorry for being a pain if this is just some stupid reading error.
but thanks in advance anyway.

Aaron
Link to comment
https://forums.phpfreaks.com/topic/5304-unable-to-connect-to-database/
Share on other sites

[!--quoteo(post=356475:date=Mar 19 2006, 08:09 PM:name=blazing_bruce)--][div class=\'quotetop\']QUOTE(blazing_bruce @ Mar 19 2006, 08:09 PM) [snapback]356475[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hello,
mysql_pconnect(); function for connecting mysql server. if you are using a simple database on your website then use mysql_connect(); it is enough.

Thank you,
Karthi keyan.
[/quote]

thanks but i have tried that too and i still get the same error!!
hello,

The error Can't connect to ... normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket filename or TCP/IP port number when trying to connect to the server.

for more reference about these type of probs [a href=\"http://www.oscommerce.info/kb/osCommerce/General_Information/Common_Problems/69\" target=\"_blank\"]http://www.oscommerce.info/kb/osCommerce/G...mon_Problems/69[/a]

Thank you,
Karthi keyan.
i had the same problem i had to remove all the variables for some reason that i do not know it just wouldnt read them the connect code i use now looks like this

[code]

<?
mysql_pconnect('localhost', 'username', 'password')
or die ("Couldn't connect to server.");

mysql_select_db('tkd1987_aaron')
or die("Couldn't select database.");
?>

[/code]


that is the only way i could get mine to connect
hopfully this helps
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.