SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot fredep57's Avatar
    Join Date
    Aug 2009
    Location
    Pacific Northwest
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird error - at least for me

    OK, I have a lot of PHP pages that use the following at the very beginning of the page:
    PHP Code:
    <?php
      session_start
    ();
      include_once 
    "functions/db_connect.php";
     
    ?>
    But on a new page I did, I get the "Access denied for user 'root'@'localhost' (using password: NO)" message. Now, I have by "db_connect.php" function so that it is used a lot without any changes.

    If I put the code from the db_connect.php function in the place of the include statement, everything is working.

    So, what can be wrong with the call for the function?

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    266
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Not very sure, but i think that the problem can be if you have the new file in another directory.
    When you include the file which has the code above, the path to "db_connect.php" should be relative to the new file you did.
    If that is the problem (you include a file that includes another php file), see this tutorial: Get Relative Path to Website Root for Includes to Access from Anywhere, maybe it helps you.
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  3. #3
    SitePoint Zealot fredep57's Avatar
    Join Date
    Aug 2009
    Location
    Pacific Northwest
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MarPlo, thanks. I looked at the tutorial and see what could have happened. Now I am going to incorporate the function from that tutorial in all my pages to make sure if I am developing something and put it in the wrong place it will get what I need from where I think it should be.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •