By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,704 Members | 1,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,704 IT Pros & Developers. It's quick & easy.

include using http://

P: n/a
*
i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include
a file. It isnt returning anything or connecting to the database (which is
what it is supposed to be doing).

any ideas? if i put in the path to the file it works, but I need it to do it
over http the rest of the code is being run over a symbolic link and I need
different connections per website.

Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
If you use include with http://, then the included file contain the result
after interpreted. What I mean is the php parser will see the included file
as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include
a file. It isnt returning anything or connecting to the database (which is
what it is supposed to be doing).

any ideas? if i put in the path to the file it works, but I need it to do
it
over http the rest of the code is being run over a symbolic link and I
need
different connections per website.


Jul 17 '05 #2

P: n/a
*
ooh, i see

could i use a echo to write out stuff that could be parsed by the php
scripts.
so i echo out
database=dbname

and then take parse it in my script ?
"Savut" <we***@hotmail.com> wrote in message
news:DB******************@news20.bellglobal.com...
If you use include with http://, then the included file contain the result
after interpreted. What I mean is the php parser will see the included file as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include a file. It isnt returning anything or connecting to the database (which is what it is supposed to be doing).

any ideas? if i put in the path to the file it works, but I need it to do it
over http the rest of the code is being run over a symbolic link and I
need
different connections per website.

Jul 17 '05 #3

P: n/a
you could do such
echo "database=dbname";

but just a note that the including page, you have to play with it and make
some workaround, why dont you just include it without using url ? Can you
explain me your situation, maybe I can suggest you a better solution.

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
ooh, i see

could i use a echo to write out stuff that could be parsed by the php
scripts.
so i echo out
database=dbname

and then take parse it in my script ?
"Savut" <we***@hotmail.com> wrote in message
news:DB******************@news20.bellglobal.com...
If you use include with http://, then the included file contain the
result
after interpreted. What I mean is the php parser will see the included

file
as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
>i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include > a file. It isnt returning anything or connecting to the database (which is > what it is supposed to be doing).
>
> any ideas? if i put in the path to the file it works, but I need it to do > it
> over http the rest of the code is being run over a symbolic link and I
> need
> different connections per website.
>
>
>



Jul 17 '05 #4

P: n/a
*
OK

i want to have two (or more) websites on a server that use exactly the same
code with only a couple of small differences in the site title, site id
number (for database purposes). I did try using symbolic links but it didnt
work very well.
"Savut" <we***@hotmail.com> wrote in message
news:Kr****************@news20.bellglobal.com...
you could do such
echo "database=dbname";

but just a note that the including page, you have to play with it and make
some workaround, why dont you just include it without using url ? Can you
explain me your situation, maybe I can suggest you a better solution.

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
ooh, i see

could i use a echo to write out stuff that could be parsed by the php
scripts.
so i echo out
database=dbname

and then take parse it in my script ?
"Savut" <we***@hotmail.com> wrote in message
news:DB******************@news20.bellglobal.com...
If you use include with http://, then the included file contain the
result
after interpreted. What I mean is the php parser will see the included

file
as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
>i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to

include
> a file. It isnt returning anything or connecting to the database (which
is
> what it is supposed to be doing).
>
> any ideas? if i put in the path to the file it works, but I need it
to do
> it
> over http the rest of the code is being run over a symbolic link and

I > need
> different connections per website.
>
>
>


Jul 17 '05 #5

P: n/a
"*" <*@*.com> wrote in message
news:<ce**********@news.netkonect.net>...

i am using include("http://".$_SERVER['SERVER_NAME']."/db.php");
Bad idea. Use include('db.php') instead. There is a HIGHLY
insecure workaround. Rename your db.php into db.txt and

include('http://' . $_SERVER['SERVER_NAME'] . '/db.txt');

It will work, but your code (including database passwords) will be
visible to anyone who by chance stumbles into your text/PHP file.
if i put in the path to the file it works,
Which is exactly how it is supposed to work.
but I need it to do it over http
No you don't.
the rest of the code is being run over a symbolic link and I need
different connections per website.


So figure out a way to include() files by their local filenames
per Web site.

Cheers,
NC
Jul 17 '05 #6

P: n/a
In article <ce**********@news.netkonect.net>, * wrote:
OK

i want to have two (or more) websites on a server that use exactly the same
code with only a couple of small differences in the site title, site id
number (for database purposes). I did try using symbolic links but it didnt
work very well.


if (isset($_SERVER['HTTP_HOST']))
{
$site = $_SERVER['HTTP_HOST'];
}
else
{
$site = 'default';
}
require_once('settings_'.$host);

Offcourse you expand this to find differences between http and https,
ports numbers, ...
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #7

P: n/a
If you have access to the webserver you're reading from you
could rename or copy the "config" file to a text file such
as:

http://".$_SERVER['SERVER_NAME']."/db.txt

That way apache won't execute it - it would just display it
(the code) as plain text.

Having said that, anything that can be read in by "include"
using "http://..." can also be read by prying eyes. It may
be convenient, or a "neat" trick, but it would not be a very
good solution for a "real world" application.

-CF

"*" <*@*.com> wrote in message
news:ce**********@news.netkonect.net...
ooh, i see

could i use a echo to write out stuff that could be parsed by the php scripts.
so i echo out
database=dbname

and then take parse it in my script ?
"Savut" <we***@hotmail.com> wrote in message
news:DB******************@news20.bellglobal.com...
If you use include with http://, then the included file contain the result
after interpreted. What I mean is the php parser will see the included
file
as you see it in browser
http://".$_SERVER['SERVER_NAME']."/db.php
Savut
http://www.savut.com

"*" <*@*.com> wrote in message

news:ce**********@news.netkonect.net...
i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include
a file. It isnt returning anything or connecting to
the database (which
is what it is supposed to be doing).

any ideas? if i put in the path to the file it works,
but I need it to
do it
over http the rest of the code is being run over a

symbolic link and I need
different connections per website.


Jul 17 '05 #8

P: n/a
If there are on the same server, you can use include() with full path to the
file
web1 : include("/home/user1/website1/file.inc")
web2 : include("/home/user1/website1/file.inc")

If not, they you must play with javascript
web1 : <script src=http://www.site1.com/js/stuff1.php>
web2 : <script src=http://www.site1.com/js/stuff1.php>

in stuff1.php, you can write something like:
<?php
echo "document.write(\"".time()."\");";
?>

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
OK

i want to have two (or more) websites on a server that use exactly the
same
code with only a couple of small differences in the site title, site id
number (for database purposes). I did try using symbolic links but it
didnt
work very well.
"Savut" <we***@hotmail.com> wrote in message
news:Kr****************@news20.bellglobal.com...
you could do such
echo "database=dbname";

but just a note that the including page, you have to play with it and
make
some workaround, why dont you just include it without using url ? Can
you
explain me your situation, maybe I can suggest you a better solution.

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
> ooh, i see
>
> could i use a echo to write out stuff that could be parsed by the php
> scripts.
> so i echo out
> database=dbname
>
> and then take parse it in my script ?
>
>
> "Savut" <we***@hotmail.com> wrote in message
> news:DB******************@news20.bellglobal.com...
>> If you use include with http://, then the included file contain the
>> result
>> after interpreted. What I mean is the php parser will see the
>> included
> file
>> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
>>
>> Savut
>> http://www.savut.com
>>
>> "*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
>> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to
> include
>> > a file. It isnt returning anything or connecting to the database (which > is
>> > what it is supposed to be doing).
>> >
>> > any ideas? if i put in the path to the file it works, but I need it to > do
>> > it
>> > over http the rest of the code is being run over a symbolic link and I >> > need
>> > different connections per website.
>> >
>> >
>> >
>>
>
>



Jul 17 '05 #9

P: n/a
Or include using include() but some server block include() using file on
another server, so I prefer script src when the application is distributed.

Savut
http://www.savut.com

"Savut" <we***@hotmail.com> wrote in message
news:FJ*******************@news20.bellglobal.com.. .
If there are on the same server, you can use include() with full path to
the file
web1 : include("/home/user1/website1/file.inc")
web2 : include("/home/user1/website1/file.inc")

If not, they you must play with javascript
web1 : <script src=http://www.site1.com/js/stuff1.php>
web2 : <script src=http://www.site1.com/js/stuff1.php>

in stuff1.php, you can write something like:
<?php
echo "document.write(\"".time()."\");";
?>

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
OK

i want to have two (or more) websites on a server that use exactly the
same
code with only a couple of small differences in the site title, site id
number (for database purposes). I did try using symbolic links but it
didnt
work very well.
"Savut" <we***@hotmail.com> wrote in message
news:Kr****************@news20.bellglobal.com...
you could do such
echo "database=dbname";

but just a note that the including page, you have to play with it and
make
some workaround, why dont you just include it without using url ? Can
you
explain me your situation, maybe I can suggest you a better solution.

Savut
http://www.savut.com

"*" <*@*.com> wrote in message news:ce**********@news.netkonect.net...
> ooh, i see
>
> could i use a echo to write out stuff that could be parsed by the php
> scripts.
> so i echo out
> database=dbname
>
> and then take parse it in my script ?
>
>
> "Savut" <we***@hotmail.com> wrote in message
> news:DB******************@news20.bellglobal.com...
>> If you use include with http://, then the included file contain the
>> result
>> after interpreted. What I mean is the php parser will see the
>> included
> file
>> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
>>
>> Savut
>> http://www.savut.com
>>
>> "*" <*@*.com> wrote in message
>> news:ce**********@news.netkonect.net...
>> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to
> include
>> > a file. It isnt returning anything or connecting to the database

(which
> is
>> > what it is supposed to be doing).
>> >
>> > any ideas? if i put in the path to the file it works, but I need it

to
> do
>> > it
>> > over http the rest of the code is being run over a symbolic link
>> > and

I
>> > need
>> > different connections per website.
>> >
>> >
>> >
>>
>
>



Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.