Results 1 to 5 of 5

Thread: Connecting to a database, A little Problem

  1. #1
    Web Extraordinaire
    Join Date
    Aug 2004
    Posts
    301
    Thanks
    0
    Thanked
    0 times in 0 posts

    Connecting to a database, A little Problem

    Hi Guys,

    I have come into a little problem connecting to a database on my test server. I cannot see anything wrong with my scripting unless i have been looking at it too long.

    Here is my code

    Code:
    <?php
         require("/config/db.config.php");
         $connection = mysql_connect($db_host, $db_user, $db_pass) or die ("Error Connection");
         echo "Connection Made";
    ?>
    There is definitly config/db.config.php and in there is definitly the following $db_host, $db_user, $db_pass.

    The details are correct also but still not having any luck. The error i am getting is:

    Warning: require(/config/db.config.php) [function.require]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\guestbook\index.php on line 2

    Fatal error: require() [function.require]: Failed opening required '/config/db.config.php' (include_path='.;C:\Program Files\xampp\php\pear\') in C:\Program Files\xampp\htdocs\guestbook\index.php on line 2

  2. #2
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    What folder is the file you've got the code in. It's looking for a config folder with db.config.php in it from wherever you're calling it

  3. #3
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Quote Originally Posted by realm
    Hi Guys,

    I have come into a little problem connecting to a database on my test server. I cannot see anything wrong with my scripting unless i have been looking at it too long.

    Here is my code

    Code:
    <?php
         require("/config/db.config.php");
         $connection = mysql_connect($db_host, $db_user, $db_pass) or die ("Error Connection");
         echo "Connection Made";
    ?>
    The require statment is wrong, it's making php look for the db.config.php in the /config system directory, require statements are realitive to the system directory, not the apache root, try
    Code:
    require("./config/db.config.php");
    instead, the dot will tell php to be relitive from the current scripts position in the system file hierarchy.
    Last edited by aidanjt; 30-06-2006 at 02:00 PM.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  4. #4
    Web Extraordinaire
    Join Date
    Aug 2004
    Posts
    301
    Thanks
    0
    Thanked
    0 times in 0 posts
    Works perfectly now, thanks a lot aidanjt that worked a treat. I thought it would be something small like might a ; or .

    Thanks again buddy.

  5. #5
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    Or in this instance you could alternativly remove the initial forward slash.
    To err is human. To really foul things up ... you need a computer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problems Connecting Laptop To PA / Amp
    By mrchu in forum Help! Quick Relief From Tech Headaches
    Replies: 16
    Last Post: 08-08-2011, 11:40 AM
  2. DVI problem, pc won't start! help needed.
    By snowwolf in forum Graphics Cards
    Replies: 1
    Last Post: 09-04-2010, 04:11 PM
  3. annoying onboard lan problem
    By uchiha_itachi in forum Networking and Broadband
    Replies: 2
    Last Post: 05-02-2006, 07:12 PM
  4. SN25P PSU or PCI-E problem!?
    By SilverFern in forum PC Hardware and Components
    Replies: 1
    Last Post: 19-01-2006, 10:51 AM
  5. Replies: 4
    Last Post: 19-09-2003, 08:25 AM

Posting Permissions

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