|
Posted by Carlo Tambuatco on 11/17/05 14:26
I have set up MySQL on my home computer, and I am writing a PHP enabled web
site to run queries on this database.
I have created a database called 'weather' on mysql that I want to access
via my website.
I have also created a user with a password (this isn't the real one, but
I'll use this to illustrate my point)
User: carlotam
Password: blah
Host: localhost
To which user I have granted all on database weather.
Using a PHP call: I try:
$username="carlotam";
$password="blah";
$database="weather";
$host="localhost";
$var = $_POST['topic'];
echo "<center><h1>ESCape Database Query</h1></center>";
echo "You have queried <b>$var</b><br><br>";
echo "Your database is: <b>$database</b>.<br>";
echo "Your username is: <b>$username</b>.<br><br>";
mysql_connect($host, $username, $password);
@mysql_select_db($database) or die("Unable to select database
<b>$database</b> on <b>$host</b>.");
mysql_close();
And I keep getting the message "Unable to select database weather on
localhost."
Is there something wrong with the above, or is there something wrong with my
MySQL server configuration? My server is up and running, so I was wondering
if anybody can help with this problem?
If this information helps: I am running MySQL 5.0.15 server on a PowerMac G4
laptop. And yes, I did check to see if the server was running before I
checked the code.
-Carlo
Navigation:
[Reply to this message]
|