connect error.

C++, C#, Java, PHP, ect...
Post Reply
User avatar
rockinliam
Posts: 466
Joined: Sun Jun 07, 2009 11:26 am

connect error.

Post by rockinliam »

What is this error? I can't work it out. Help appreciated.
http://mrangrytroll.com/development/rate_mate/

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/93/6823793/html/development/rate_mate/connect.php on line 3
Could not connect to db

Code: Select all

<?php

$db = mysql_connect("localhost","ratemate","PASSWARD") or die("Could not connect to db");
if(!$db)
die("no db");
if(!mysql_select_db($db , "ratemate"))
die("No Database Selected");

?>
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: connect error.

Post by SpiritWebb »

Code: Select all

<?php

$db = mysql_connect("localhost","ratemate","PASSWARD") or die("Could not connect to db");

Try changing the quotes to the single ' and see what happens...also adding the mysql_error() to it, will help debug with a better understanding of whats going on here if it fails again

Code: Select all

<?php

$db = mysql_connect('localhost', 'ratemate', 'PASSWARD') or die('Could not connect to db: ' . mysql_error());

Image

Image
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: connect error.

Post by Chris »

By the looks of it your MySQL server is running on a different port. You'll have to find out what port, or change it.

Code: Select all

mysql_connect("localhost:port", "username", "password");
 
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “Coding”