[RESOLVED] select database problem
PHP Code:
$con = mysql_connect("localhost","user1","password") or die("Cannot connect");
mysql_select_db("pmonty7_dsd", $con) or die("Cannot select database");
$query = "SELECT * FROM randquote ORDER BY Rand() LIMIT 1";
$result = mysql_query($query,$con) or die("Result Query Error");
while($rows = mysql_fetch_array($result))
{
echo $rows['quote'] . " " . $rows['LastName'];
echo "<br />";
}
mysql_close($con);
I am getting the die message "Cannot select database"
I have no idea host is all workign fine and so is phpmyadmin and so on. But cant figure it out. also the name and table name are 100% correct.
Any idea guys?
Re: select database problem
bump your error level up (with error_reporting) and see what actual error the sql lib gives you
PHP Code:
error_reporting(E_ALL)
Re: select database problem
Just added it now and still get the same message "Cannot select DB"... is it not recognizing the dbname or is it a issue on the mysql configuration end?
Re: select database problem
hmm i added mysql_Error() and it says access denied for 'pmonty7_admin'@'localhost' to 'pmonty7_dsd'
Re: select database problem
Quote:
Originally Posted by
SharpCode
hmm i added mysql_Error() and it says access denied for 'pmonty7_admin'@'localhost' to 'pmonty7_dsd'
Check whether user1 has appropriate permission to access your database pmonty7_dsd.
:wave:
Re: select database problem
yeh seems the user i made wasn't added to the database... common sense -.-