Mysql prolem
Posted by: Luca (---.i07-32.onvol.net)
Date: November 30, 2012 09:19AM

Could not connect to MySQL: Access denied for user 'dbuser'@'localhost' (using password: YES)


Cant seem to arrange this error. (user and pass were set right as they work on phpmyadmin but connection with mysql_connect doesn't work and shows that error)

Options: ReplyQuote
Re: Mysql prolem
Posted by: RiggsFolly (---.as13285.net)
Date: November 30, 2012 10:18AM

Post your php code for the mysql_connect

Options: ReplyQuote
Re: Mysql prolem
Posted by: Luca (---.i07-31.onvol.net)
Date: November 30, 2012 10:42AM

<?php

$dbhost ="127.0.0.1";
$dbuser="root";
$dbpassword="password" ;


$link = mysql_connect('dbhost','dbuser','dbpassword');
if (!$link) {
die('Could not connect to MySQL: ' . mysql_error());
}
echo 'Connection OK'; mysql_close($link);
?>


now its producing a different error


Could not connect to MySQL: php_network_getaddresses: getaddrinfo failed: No such host is known.

even after changing the host to localhost from 127.0.0.1 , the same error is shown

Options: ReplyQuote
Re: Mysql prolem
Posted by: Luca (---.i07-31.onvol.net)
Date: November 30, 2012 10:45AM

Tried this and the error occurs again of the access denied --

$dbuser="root";
$dbpassword="password" ;


$link = mysql_connect('localhost','dbuser','dbpassword');
if (!$link) {
die('Could not connect to MySQL: ' . mysql_error());
}
echo 'Connection OK'; mysql_close($link);
?>

Options: ReplyQuote
Re: Mysql prolem
Posted by: RiggsFolly (---.as13285.net)
Date: November 30, 2012 05:53PM

Derrrrr???

try using this


$link = mysql_connect( $dbhost, $dbuser, $dbpassword );


Then you will be using the contents of the 3 variables you set up and not 3 text strings containing the wrong values for host, user and password.

I woudl also use the word locahost instead of 127.0.0.1

Options: ReplyQuote


Sorry, only registered users may post in this forum.