currently attempting to learn the basics of MySQL and PHP, which was going OK until I wanted to connect to a database.
I've created a database and put in some tables, set up a user with username and password, all through MySQL and phpMyAdmin.
I've two PHP files, the first storing the usual:
<?php
$db_host='localhost';
$db_database='stevet70_test';
$db_username='stevet70_test';
$db_password='password';
?>
the second doing the connecting and selecting:
<?php
// Include our login information
include('db_login.php');
// Connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die ("Could not connect to the database: <br />". mysql_error( ));
}
// Select the database
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
die ("Could not select the database: <br />". mysql_error( ));
}
?>
I've actually tried going through the whole process on two different hosting accounts. The PHP files are on the same hosting as the database, but all I get is:
Could not select the database:
Access denied for user 'stevetur_test'@'localhost' to database 'stevetur_test'
Where am I going wrong?
I've also tried putting in the wrong password, which gives a much longer error message, suggesting that I'm connecting to MySQL OK, it's just the actual database.
Any help much appreciated
I've created a database and put in some tables, set up a user with username and password, all through MySQL and phpMyAdmin.
I've two PHP files, the first storing the usual:
<?php
$db_host='localhost';
$db_database='stevet70_test';
$db_username='stevet70_test';
$db_password='password';
?>
the second doing the connecting and selecting:
<?php
// Include our login information
include('db_login.php');
// Connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die ("Could not connect to the database: <br />". mysql_error( ));
}
// Select the database
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
die ("Could not select the database: <br />". mysql_error( ));
}
?>
I've actually tried going through the whole process on two different hosting accounts. The PHP files are on the same hosting as the database, but all I get is:
Could not select the database:
Access denied for user 'stevetur_test'@'localhost' to database 'stevetur_test'
Where am I going wrong?
I've also tried putting in the wrong password, which gives a much longer error message, suggesting that I'm connecting to MySQL OK, it's just the actual database.
Any help much appreciated