I have a connection problem that I have been unable to solve after searching the web and the mysql mailing-lists. I'm connecting to a local database using PHP. It's a pretty simple and straightfoward setup, a user logs in and the links they have access to are displayed (change user info, update password, etc). I can log in with the initial links displayed (database connection is made), but after that (either by clicking a link or hitting refresh on the same page I just logged in to) I get the following error:
Access denied for user: '@localhost' to database 'my_DB_name'
The only way I have been able to work around this is by giving Select, Insert, Update, Delete permissions to the host 'localhost' (no user or password) in the mysql.users table. If I give this host no permissions, the script works as described above, only logging in once. Below is the PHP db connect function that I am using (included via require_once on all pages). I have tried to connect both with root and another user I created with all permissions. I have also tried creating a user in the mysql.db table with 'localhost - my_DB_name - my_DB_user' and all permissions.
<?php function db_connect() { $result = mysql_pconnect('localhost', 'my_DB_user', 'DBPASSWORD'); if (!$result) return false;
if (!mysql_select_db('my_DB_name')) return false;
return $result; } ?>
Is there something I've overlooked here in my connection setup? I can't give the localhost host permissions in my production environment for security reasons. Any help, suggestions, or ideas are appreciated. (Using - MySQL 4.0.13, PHP 4.3.2)
Thanks
_________________________________________________________________
Want to check if your PC is virus-infected? Get a FREE computer virus scan online from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]