I have installed XAMPP for Mac on my computer, and it's installed fine, I get the 'Welcome to XAMPP' page when I go to http://localhost/, I can access phpMyAdmin, etc. the installation is fine. I've made a new database in phpMyAdmin called store as it will be a database for an online store, I've also made a user and assigned full control on that database at the moment. I'm doing this all locally because I haven't got a host yet by the way, oh and by the way Apache, MySQL and FTP are all running. So I've got a config.php file where I try to connect to the database in phpMyAdmin, I've put in the code to connect to it:
- Code: Select all
$db_host = "localhost";
$db_username = "daniel";
$db_pass = "admin";
$db_name = "store";
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
I then made a new PHP file in the same directory which just quickly tests the connection. test.php:
- Code: Select all
echo "<h1>Success! Connection to database established!</h1>";
When I run the PHP which parses correctly through my browser, I go to http://localhost/store/test.php I get the following message through my browser:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Sun Jul 24 15:27:06 2011
Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1
If I run a basic PHP file which just echos the text hello! it works perfectly fine, it was also in the same directory which showed it was working.
It's telling me it can't find the database I believe, so i'm stuck because I can't connect to the database. Does anyone out here know how I would connect to the database I made in phpMyAdmin, which is hosted locally using XAMPP? I would like to connect to it using PHP.
Thank you in advance. Dan.