Php include help...!


#1

I’m basically trying to pull some posts from my SMF forum to my website but I keep getting an error:


Warning: include(/home/username/mydomain.com/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=5;length=2500) [function.include]: failed to open stream: No such file or directory in /home/.norna/ username/mydomain.com/includes/main.php on line 3

Warning: include() [function.include]: Failed opening ‘/home/ username/mydomain.com /forums/SSI.php?ssi_function=boardNews;board=2.0;limit=5;length=2500’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/.norna/ username/mydomain.com/includes/main.php on line 3

my URL reads something like this mydomain.com/index.php?id=main, inside the “main.php” i put the following:

<?php include($_SERVER["DOCUMENT_ROOT"].'/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=5;length=2500'); ?>

i also tried putting <?php include("/home/.norna/username/mydomain.com/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=5;length=2500"); ?> just to make sure but same errors showing up.

Any help is appreciated…


#2

you should remove “home/username/mydomain.com” in the path.

try include(“forums/SSI.php”);

and here are some tips:

“forums/ssi.php” starts from current folder
"…/" goes to parent folder
"/" goes to root folder

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#3

ok still no good…same errors. :frowning:


#4

this error indicates that php can’t locate the file.

May I know where the file that executes include is and where the SSI file is?

I can give you an example.

if you have a file test.php in domain.com/test folder and you want to include a file test2.php in domain.com/test/forums folder, the codes in test.php file will be something like include(“forums/test2.php”);

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#5

I’m no PHP expert (far from it), but as I understand it, the line you are using above should indeed return the full path to SSI.php.

Have you checked all the obvious things? Such as, does /mydomain.com/forums/SSI.php actually exist? Is the capitalization for the directory and file name correct? Remember, under Linux SSI.php and ssi.php are considered different file names.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#6

if you use $_SERVER[“DOCUMENT_ROOT”], it always returns the root folder which is your “mydomain.com

where is your folder “forum” located? Is it located in the root folder? Can you access the file from “http://www.mydomain.com/forums/ssi.php”?

The problem must be that you are looking for the file in the wrong folder.

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#7

this is driving me nuts! :confused:

i single out the problem based on your suggestions but i still get no luck.

The paths are correct. I inserted test.php in “forums/” in replace of ssi.php, and it works!

however, for some reason, inserting just ‘forums/test.php’ in the include did not work, i had to insert "$_SERVER[‘DOCUMENT_ROOT’] aswell to make it work…

At this point, i thought the culprit must be the ssi.php; so i went ahead and setup a localhost and
include it with the direct link, http://mydomain.com/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=1;length=2500, just to see
if it gives me an error. Guess what, it works!

maybe this is an issue with DH’s php setup, and i need to enable some options in order for this to work? I’ve heard you can
install a custom php in your account but i’m not really good a that. :confused:

i know i’m one step closer nailing this thing! :slight_smile:


#8

What does SSI.php actually do?


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#9

you mean just include “forums/SSI.php”?

Well it does nothing, i get no errors. I assume it reads the correct path. But in order for it to function i have to include “?ssi_function=boardNews;board=2.0” with it. That’s where the trouble begins…


#10

So the problem must be in the function, and not in the inclusion itself.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#11

thanks for the suggestions guys but i think i figured it out. =)

<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://mydomain.com/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=1;length=2500"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?>

instead of:

<?php include($_SERVER['DOCUMENT_ROOT'].'/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=1;length=2500'); ?>

#12

Wait a minute. Are you saying that SSI.php is not on the same domain as the include?


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#13

No, they are on same domain.

Basically, <?php include($_SERVER['DOCUMENT_ROOT']."/includes/ssi.php"); ?> should work with no problem.

But the reason i’m getting an error was because i’m passing variables to an included file, that is, “?ssi_function=boardNews;board=2.0;limit=1;length=2500”

After reading the wiki i found out the only way for those to work together is to install a custom php or simply use cURL.


#14

Okay. I get it now.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)