Trouble with connecting to mysql.
I am getting the following 2 messages:
Warning: mysql() [function.mysql]: Access denied for user 'apache'@'localhost' (using password: NO)
Warning: mysql() [function.mysql]: A link to the server could not be established
Any suggestions.
You need to use mysql_connect() to connect to the database server first. If you are already using it, verify that you are providing your database username and password properly. It should look like:
mysql_connect('localhost', 'my-db-username', 'my-db-password');
Note: You need to create a database before using it, if you have not already done so. You can add a database to your account using your account control panel (http://system.freepgs.com/database.php).
Thanks for the feedback...
I have setup my database in my control panel. I've got my db_name, db_username and db_password.
However, I am not sure how to make sure that I am using mysql_connect() to connect to the database server first, as you suggested.
This is the mysql.lib file that I have installed on the web server:
<?
$connected = false;
function c()
{
global $db_host, $db_login, $db_pswd;
$db = @mysql_connect($db_host, $db_login, $db_pswd);
$connected = true;
return $db;
}
function q($q_str)
{
global $db_name, $connected;
if(!$connected)
{
c();
}
$r = mysql($db_name, $q_str);
return $r;
}
function d($db)
{
@mysql_close($db);
}
function e($r)
{
if(@mysql_numrows($r))
return 0;
else return 1;
}
function f($r){
return @mysql_fetch_array($r);
}
function nr($r){
return @mysql_num_rows($r);
}
?>
Do you have a config file? If so, look for
$db_host = "localhost"
$db_login = DATABASE USERNAME
$db_pswd = DATABASE PASSWORD
$db_name = DATABASE NAME
There's gotta be a config file somewhere.