I am trying to connect to a mysql database using php. I created a database called 'dbone' with phpmyadmin and then created a table called 'contacts' inside this database. The username for the database is 'testuser' and the password is 'testpassword'.
I then tried to connect to the database file using the following .php file:
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
I saved the above file in the following location:
I then typed the following into my browser to try to connect to the database:
The following error message then came up in the browser window:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'testuser'@'localhost' (using password: YES) in /Applications/XAMPP/xamppfiles/htdocs/test.php on line 5
Unable to select database
Could anyone tell me what I am doing wrong and how can I connect to the database using php?