Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Wed Sep 05, 2007 7:34 am Reply with quote

A couple questions about using $_SERVER['DOCUMENT_ROOT']

I am one level below the config.php file and am in my admin directory. I am having trouble connecting with the database and it is because I think the code cannot see the config.php

I used this to make sure I could find the config.php:

$CONF_PATH = $_SERVER['DOCUMENT_ROOT'];

then

require $CONF_PATH."xxxxx/includes/mysql.php";
require $CONF_PATH."xxxxx/includes/db.php";
require $CONF_PATH."xxxxx/config.php";

I am on a MAC OSX 10.4 Server

The $_SERVER['DOCUMENT_ROOT']; returns

/Library/WebServer/Document/

so it would be logical to concatenate that with "xxxxx/config.php";

Does it matter in what order I place these?

Code:
require $CONF_PATH."xxxxx/includes/mysql.php"; 

require $CONF_PATH."xxxxx/includes/db.php";
require $CONF_PATH."xxxxx/config.php";
 
View user's profile Send private message Visit poster's website ICQ Number
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Sep 05, 2007 5:36 pm Reply with quote

Does your PHP user have permissions to access that file? You can always check using the file_exists function

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
gotcha
Regular
Regular



Joined: Mar 14, 2005
Posts: 91

PostPosted: Wed Sep 05, 2007 6:12 pm Reply with quote

You should call config.php first as it contains the info to connect to the db.
 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Thu Sep 06, 2007 7:19 am Reply with quote

Thanks.. I changed it and it did the trick.
 
gregexp
The Mouse Is Extension Of Arm



Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Thu Sep 06, 2007 8:32 pm Reply with quote

Just for information Donovan, you must think of includes as a part of the script.

For example,

If I was to write a script like this:
index.php
Code:


<?php
include('info.php');
echo $info;
?>


And I made a script like this:

Code:


<?php
$info='hello';
?>


The output would be as you think, hello.

But in the end, you must think of index.php written like this:

Code:


<?php

$info='hello';
echo $info;
?>


It may not be perfect, but it is how I think of it and I think it's rather easy to remember.

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©