Hello,
I know it is not the best practice but I am working on a site for a friend and I am trying to figure out a weird issue with PHP/MySQL. I try logging in as the user root (I know this is not recommended), and the root password, which are both stored in globals. I’ve had the following code which was working for several years, until one day it stopped work mysteriously.
I am trying the following code here:
[code=php]
<?php
$con = mysql_connect($GLOBALS[“dbHost”], $GLOBALS[“dbUser”], $GLOBALS[“dbPass”]);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db($GLOBALS[“dbName”]);
mysql_query(“SET NAMES ‘utf8’ COLLATE ‘utf8_general_ci'”);
$sql=”SELECT * FROM `householdinfo_” . $year . “` WHERE geography =’99’ && subgeography ='” . $subgeoStr. “‘ && familytype LIKE'” . $famTypeStr . “%'”;
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo $row[‘geography’] . “;” . $row[‘subgeography’] . “;” . $row[‘familytype’] . “;” . $row[‘familycount’] . “;” . $row[‘medianincome’];
}
mysql_close($con);
?>
I have double checked the contents of the globals, and the username/password/database defined in the globals are correct.
Howevere I get the following error:
[code=php]
Could not connect: Access denied for user ‘www-data’@’localhost’ (using password: NO)
Is there any reason why when I try logging in as “root” it returns an error saying that I am trying to login as www-data without a password?
I have googled this for quite some time and the general result is either that I have run out of available connections from another PHP script not closing the mysql connecetion properly. However I have been unable to verify if that’s the case here.