ConnorMcLeod
New Member
- Messages
- 21
- Reaction score
- 0
- Points
- 0
Hi all,
I took the following steps to prepare my first MySQL database and tried to access it from PHP.
1) used MySQL(R) Database to create a database
2) created PHP script to first connect to localhost
and then select database as below.
mysql_select_db($dbname) or die ('Error selecting database');
There was no error connecting to the host,
but system "Error selecting database" to me.
$dbname is the same name as shown in MySQL Database , also the same as in the left panel of PHPMyAdmin (this is the only database I created, and there is a default (?) database named information_schema).
Is there anything else I need to do?
The full PHP code i used to connect and select database is below.
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql server');
mysql_select_db($dbname) or die ('Error selecting database');
mysql_close();
Please help. I am new to PHP and stuck.
I took the following steps to prepare my first MySQL database and tried to access it from PHP.
1) used MySQL(R) Database to create a database
2) created PHP script to first connect to localhost
and then select database as below.
mysql_select_db($dbname) or die ('Error selecting database');
There was no error connecting to the host,
but system "Error selecting database" to me.
$dbname is the same name as shown in MySQL Database , also the same as in the left panel of PHPMyAdmin (this is the only database I created, and there is a default (?) database named information_schema).
Is there anything else I need to do?
The full PHP code i used to connect and select database is below.
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql server');
mysql_select_db($dbname) or die ('Error selecting database');
mysql_close();
Please help. I am new to PHP and stuck.