WAMPfilter: Just upgraded to PHP5 and MySQL5, and now my scripts are getting access denied when connecting to the database. I can login from the command line with the same account just fine.
Many thanks for the suggestions to my
previous question about PHP under IIS (ick).
I've persuaded the CTO to allow me to switch to Apache2 as we migrate the production server to new hardware. I figured now would be a good time to upgrade to PHP5 and MySQL5 as well--because I like pain.
Everything is going well, but my PHP scripts,
which I changed to use mysqli_connect instead of mysql_connect, are now getting access denied:
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'calendar'@'localhost' (using password: YES)
Where is gets weird: With the same password and username I can login to mysql from the command prompt. Also, my install of phpmyadmin is working just fine, so PHP *can* talk to the mysql service.
What am I doing wrong? I dont think this is the issue, but just for kicks here is the function that's throwing the error:
$dbhost="localhost";
$dbusername="calendar";
$dbuserpass="____"; // obscured for public consumption
$default_dbname="calendar";
$mysqli_ERRNO = ';
$mysqli_ERROR = ';
function db_connect($dbname=') {
global $dbhost, $dbusername, $dbuserpass;
global $mysqli_ERRNO, $mysqli_ERROR;
$link_id = mysqli_connect($dbhost, $dbusername, $dbuserpass, $default_dbname);
if (!link_id) {
$mysqli_ERRNO = 0;
$mysqli_ERROR = "Connection to $dbhost failed.";
return 0;
}
ELSE IF (empty($dbname) && !mysqli_select_db($default_dbname)) {
$mysqli_ERRNO = mysqli_errno();
$mysqli_ERROR = mysqli_error();
return 0;
}
ELSE IF (!empty($dbname) && !mysqli_select_db($dbname)) {
$mysqli_ERRNO = mysqli_errno();
$mysqli_ERROR = mysqli_error();
return 0;
}
ELSE RETURN $link_id;
}
posted by Captain_Tenille at 2:55 PM on February 2, 2006