User access to MySQL when running PHP script
I need some help with a DB/PHP user access issue.
I setup PHP and MySQL as per the instructions here:
I know both PHP and MySQL are working OK. In fact, I can write a PHP script that connects to the DB and inserts some data from the command line with a MySQL user I specified ('user'@localhost). All good.
The problem I am having is when I try to insert some data into a DB from PHP when the PHP script is run from a URL. I installed Apache and everything with the server is working ok. I get an 'Unable to select database' error message when I try to connect to the database with any MySQL account other than the root. I granted a user access to all privileges for the database in question, and it's still unable to connect.
Basically I don't want to have to use the root account for these DB scripts, but I can't get a user account I created to work.
To connect to the DB, I am using standard PHP code…
$user = 'theuser';
$database = 'databasename';
$password = 'thepassword';
$server = 'localhost';
$connection = mysql_connect($server,$user,$password);
@mysqlselectdb($database) or die( "Unable to select database");
This must be something really simple, and I am not as well-versed with these kinds of issues as I would have liked. Thanks for any assistance.
-et