473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Include file wont get processed by php???

I have a bunch of includes that are includes of includes included
includicly... so they must be linked to the site root. Heres an
example...

require_once("http://localhost/includes/dbConnect.php");

If I name the include file with an .inc extension or even an .asp
extension the code gets processed, but not with a .php extension. Any
suggestions? -Nick
Jul 17 '05 #1
7 2209
"Nick" <nb********@hotmail.com> wrote in message
news:ce**************************@posting.google.c om...
I have a bunch of includes that are includes of includes included
includicly... so they must be linked to the site root. Heres an
example...

require_once("http://localhost/includes/dbConnect.php");

If I name the include file with an .inc extension or even an .asp
extension the code gets processed, but not with a .php extension. Any
suggestions? -Nick


becouse when it is .php and you try to include it over a url (ie: http://),
then the server is trying to interpet it.
when you use .inc the server just sends the whole file.

try typing the url into your browser and see what happens, what your browser
sees is what the include will see. (over http url that is)

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
So as to make it painfully clear to the O.P., your includes should be file
paths, not URLs, for PHP you want processed. e.g.
include('test.php');
include('./test.php');
include('../includes/something.php');
include('/var/www/html/includes/test.php');
CountScubula wrote:
"Nick" <nb********@hotmail.com> wrote in message
news:ce**************************@posting.google.c om...
I have a bunch of includes that are includes of includes included
includicly... so they must be linked to the site root. Heres an
example...

require_once("http://localhost/includes/dbConnect.php");

If I name the include file with an .inc extension or even an .asp
extension the code gets processed, but not with a .php extension. Any
suggestions? -Nick


becouse when it is .php and you try to include it over a url (ie:
http://), then the server is trying to interpet it.
when you use .inc the server just sends the whole file.

try typing the url into your browser and see what happens, what your
browser sees is what the include will see. (over http url that is)

Jul 17 '05 #3
"Agelmar" <if**********@comcast.net> schrieb im Newsbeitrag
news:c2*************@ID-30799.news.uni-berlin.de...
So as to make it painfully clear to the O.P., your includes should be file
paths, not URLs, for PHP you want processed. e.g.
include('test.php');
include('./test.php');
include('../includes/something.php');
include('/var/www/html/includes/test.php');


include($_SERVER['DOCUMENT_ROOT']."/includes/myinclude.php");

HTH
Markus
Jul 17 '05 #4
Is there a better way to link the includes to the site root then? The
only probelm I have with naming my includes.inc is that I wont get php
syntax highlighting in my editor (dreamweaver). -Nick
Jul 17 '05 #5
Nick wrote:
Is there a better way to link the includes to the site root then? The
only probelm I have with naming my includes.inc is that I wont get php
syntax highlighting in my editor (dreamweaver). -Nick


read the responses to your post. you simply don't want the file to be parsed
by the webserver first, hence you use a file path. You should never be doing
something like include('http://www.mysite.com/something.php'); because then
the webserver will be parsing it first. Rather, just do
include('something.php') or
include($_SERVER['DOCUMENT_ROOT'].'/includes/myfile.php'); etc. If you
preface it with http://, it's going to get requested from the webserver,
which you don't want. You want PHP to fetch the raw php file off the disk.

-Ian
Jul 17 '05 #6
Thanks all. $_SERVER['DOCUMENT_ROOT'] is what I was looking for. I
guess I have to initialize that in php.ini as "DOCUMENT_ROOT"? -Nick
Jul 17 '05 #7
Nick wrote:
$_SERVER['DOCUMENT_ROOT'] is what I was looking for.
I guess I have to initialize that in php.ini as "DOCUMENT_ROOT"?


No. Just do

require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/dbConnect.php';
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Adam | last post by:
Hi All, Is it possible to use includes dynamically in html. Hopefully the following example will give an idea what I am rying to do. Thanks in advance Adam <script language="javascript">
21
by: .:mmac:. | last post by:
I have to update a page every week. I get the page ahead of time so I used the "scheduled includes" webbot in Frontpage only to find that I would have to refresh the page every week to have it...
3
by: TNG | last post by:
Hi, I try to accomplish something like this: <!--#include file="menu_<%response.write (strproduct)%>.html"--> But unfortunally, I quess there is something with my syntax... any idea ?
6
by: Puzzled | last post by:
This is a weird problem, but perhaps someone else has seen it before (I hope!) If I use a fully qualified include call include ( 'http://localhost/subtree/filename.php') I get an 'undefined...
6
by: atv | last post by:
Alright, i have some questions concerning include files en global variables.I hope someone is willing to answer these. 1).Why is it that if i define a global variable in a file, say main.c, and...
9
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I...
12
by: Francois Grieu | last post by:
Can #include safely use a preprocessing token, as in #define HEADERFILE "stdio.h" #include HEADERFILE int main(void) {return printf("Hello, world\n")*0;} TIA, François Grieu
4
by: darrel | last post by:
I'm trying to load an include dynamically. So, I'm writing out the include tag via a response.write: response.write("<!--#include virtual='" & contentIncludeFile &"' -->") however, that's...
3
by: Andy Fish | last post by:
Hi, In an asp.net application, I have seen some lines like this: <!-- #Include File="xyz.html" --> and I can see what happens when the included file contains just text and html, but I can't...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.