...

View Full Version : another PHP error with connection to a database



briintex1
01-15-2004, 07:02 AM
Does anyone see anything that is out of the ordernary with my code, I have made sure that the username and password are 100% correct but I keep getting this one error, and it is something that I am not familar with...I will post it at the end of the code, but this is the code, minus the actual password

<?
$dbh=mysql_connect ("localhost", "stevenbr", "password") or die ('I cannot connect to the database because: ' . mysql_error());
$display = mysql_select_db ("nursing_Nursing");

extract($_GET);
$query = "select * from $display";

if(!isset($display))
{
$display = "nursing";
}

$result = mysql_db_query($dbh, $query) or die ('Sorry we can not use the database: ' . mysql_error());
?>
some html code is here
<?
echo $obj[1];
?>

<?
echo $obj[2];
?>
close of html code
<?
mysql_free_result($result);

mysql_close($db);
?>

the error is
Sorry we can not use the database: Access denied for user: 'nursing_stevenbr@localhost' to database 'Resource id #2'

firepages
01-15-2004, 03:14 PM
suspect this will fix ...

mysql_select_db( 'nursing_Nursing', $dbh) or die ('Can\'t use nursing_Nursing: ' . mysql_error());

...if not then you probably have the correct permissions to connect to localhost but not for the nursing_Nursing database , in which case you need to add the user stevenbr to nursing_Nursing



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum