cancel
Showing results for 
Search instead for 
Did you mean: 

php & MySQL connection...

nytmyst
Newbie
Posts: 7
Registered: ‎14-04-2010

php & MySQL connection...

Hi All, me again, the noob  Cheesy
I'm trying to connect to my MySQL database and use a simple select statment but am getting the following error returned:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
My php file looks like this :
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("username_pn", $con);
$result = mysql_query("SELECT * FROM subscriber");
while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }
mysql_close($con);
?>

I think its the 'localhost' parameters.
Can anybody shed any light on this?
Many thanks.
1 REPLY 1
jelv
Community Veteran
Posts: 26,786
Thanks: 990
Fixes: 10
Registered: ‎10-04-2007

Re: php & MySQL connection...

When you activated MySQL you should have received an email giving the server name (rumpus or humbug), username and password.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)