You are invited to Log in or Register a free Frihost Account!

PHP script has MSQL access denied

I'm getting an access denied error. I suspect it's the host name or version problems with passwords or something simple. It's running locally fine on windows 2000, apache, MySQL 5. I have plugged the following into data access class:

(changed to protect my privacy)

$CCConnectionSettings = array (
"MyInfo" => array(
"Type" => "MySQL",
"Database" => "johnaja_myinfo",
"Host" => "",
"Port" => "",
"User" => "johnaja_john",
"Password" => "PASSWORD",
"Persistent" => true

I get the following in the browser when I try to access a page that makes it's first call to the database. Any idea where is coming from? I've never heard of them. Thanks:

Warning: mysql_pconnect(): Access denied for user: '' (Using password: YES) in /home/johnaja/domains/ on line 97
Database error: cannot connect to Database Access denied for user: '' (Using password: YES)
MySQL Error
Session halted.
Try ths, just include it on any page you need a connection:


//## Connect ##//

$connection = mysql_connect($host,$user,$password)
or die (header("Location: dbdown.php"));

$database = "DBNAME";
$db = mysql_select_db($database,$connection)
or die ("Couldn’t select database.");


Change dbdown.php to an error page if your database is unnavailable, or remove 'or die (header("Location: dbdown.php"))' if you don't want that.

Dont forget to close the connection at the end of each script:


<? if (isset($connection)){ mysql_close($connection); } ?>

Hope that heps, if it doesnt work you're entering either the wrong username, password or database name as this is what I use and it works fine.

PS, dont put your password on the forum!!
Your code gave me the clue I needed. It was using localhost rather than my domain as the server name. I should have thought of that. Something told me MySQL might be running on another box.

Never fear, I did not post any of my real information. Password and everything else was all changed for the sample code I posted.

Thanks again.
Related topics
Norton Systemworks 2003 - Access Denied : Drive C
Phoenix free PHP scripts
error in my PHP script
Access denied as Admin in phpNuke
PHP Script- How can we install it
Preventing bad PHP script calls
array check box on php script using $_POST
php script not loading
PHP script authorization monthly
PHP script to create email addresses/ftp accounts/etc...
php script for Changing file permissions & owner
Uploading an Image using PHP script - RESOLVED
Access Denied for user ODBC@localhost
[Help] php script to post to twitter
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.