The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Warning: mysql_connect(): Access denied for user '****'@'localhost' (using password: NO)
Mavrik347
post Feb 12 2011, 03:39 PM
Post #1


Member
***

Group: Members
Posts: 31
Joined: 24-November 06
Member No.: 1,107



http://www.sev3rance.com/mav/web/

Hi guys, I can't fathom this at all so I was hoping someone had come across this before, when you go on the website news.php is loaded automatically by index.php as the pages default content. However, click "News" to reload news.php or click "Contacts" and then go back to "News" and the second time it loads it fails with:

QUOTE
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'default_user'@'localhost' (using password: NO) in /home/default_user/public_html/mav/web/pages/news.php on line 2
Connect Fail:Access denied for user 'default_user'@'localhost' (using password: NO)


The code to connect to the database is this:
"default_user", "forum_user" and "forum_password" are used instead of actual login details for obvious reasons.
config.php
CODE
$db_host = 'localhost';
$db_user = 'forum_user';
$db_pass = 'forum_password';

index.php
CODE
include 'config.php';
include 'pages/news.php';

news.php
CODE
$con = mysql_connect($db_host,$db_user,$db_pass);
if (!$con)
    {
    die('Connect Fail:' . mysql_error());
    }    
$db_select = mysql_select_db(sever_ipb3, $con);
if (!$db_select)
    {
    die ("DB Select fail:" . mysql_error());
    }



However, if I change the code in news.php to type in the variables manually like this:
news.php
CODE
$con = mysql_connect(localhost,forum_user,forum_password);
if (!$con)
    {
    die('Connect Fail:' . mysql_error());
    }    
$db_select = mysql_select_db(sever_ipb3, $con);
if (!$db_select)
    {
    die ("DB Select fail:" . mysql_error());
    }

Then it works every time... So why is it not picking up config.php the second time? sad.gif index includes it and as the page never refreshes index.php is always the master page, just loading different pages into a div.


Any help would be so so appreciated.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 10:59 AM