User access to MySQL when running PHP script

All,

I need some help with a DB/PHP user access issue.

I setup PHP and MySQL as per the instructions here:

http://library.linode.com/databases/mys … 0.04-lucid">http://library.linode.com/databases/mysql/ubuntu-10.04-lucid

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

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct