php include help...!
Posted by: chrisfz
Posted on: 2007-01-18 21:29:00
I'm basically trying to pull some posts from my SMF forum to my website but I keep getting an error:
Posted by: chrisfz
Posted on: 2007-01-18 21:29:00
I'm basically trying to pull some posts from my SMF forum to my website but I keep getting an error:
Posted by: nathan823
Posted on: 2007-01-18 21:31:00
you should remove "home/username/mydomain.com" in the path.
try
Posted by: chrisfz
Posted on: 2007-01-18 21:40:00
ok still no good...same errors. :(
Edited by chrisfz on 01/18/07 09:44 PM (server time).
Posted by: nathan823
Posted on: 2007-01-19 01:39:00
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");
Posted by: Raz2133
Posted on: 2007-01-19 02:06:00
In reply to:<?php include($_SERVER["DOCUMENT_ROOT"].'/forums/SSI.php?ssi_function=boardNews;board=2.0;limit=5;length=2500'); ?>
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
Posted by: nathan823
Posted on: 2007-01-19 02:34:00
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.
Posted by: chrisfz
Posted on: 2007-01-19 11:46:00
this is driving me nuts! :/
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. :/
i know i'm one step closer nailing this thing! :)
Posted by: scjessey
Posted on: 2007-01-19 11:54:00
What does SSI.php actually do?
Posted by: chrisfz
Posted on: 2007-01-19 12:11:00
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...
Posted by: scjessey
Posted on: 2007-01-19 12:32:00
So the problem must be in the function, and not in the inclusion itself.
Posted by: chrisfz
Posted on: 2007-01-19 16:10:00
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'); ?>
Posted by: scjessey
Posted on: 2007-01-19 16:16:00
In reply to:i think i figured it out
Wait a minute. Are you saying that SSI.php is not on the same domain as the include?
Posted by: chrisfz
Posted on: 2007-01-19 16:45:00
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.
Posted by: scjessey
Posted on: 2007-01-19 18:55:00
Okay. I get it now.