Re: Calling a php file from another on apache server [message #181078 is a reply to message #181077] |
Wed, 10 April 2013 20:11 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 4/10/2013 3:49 PM, Jordan Thompson wrote:
> Hi there. I am new to php. I want a top-level php file to call another that will generate html. When I access the top-level file, I only get:
> "hello from top"
>
> I checked the logs and there are no errors. "Hello.txt" is generated in the htdocs folder, so I know that the lower-level file is executed correctly,
>
> Here is the top-level php file ("top.php") that is located in the htdocs folder:
> <?php
> session_start();
> echo '<!DOCTYPE HTML>';
> echo '<html>';
> echo 'hello from top';
> exec("php hello.php");
> echo '</html>';
> ?>
>
> Here is the lower-level php file ("hello.php") that is also located in the htdocs folder:
> <?php
> session_start();
> echo "hello from bottom";
> phpinfo();
> touch("hello.txt");
> ?>
>
>
> This should be really easy, but I am very confused.
>
> thanks in advance!
>
First of all, do you have permission to issue the exec() function? Many
shared systems have it disabled for security reasons.
If you do have permission, is the php executable available to you?
Again, on a shared system, it may or may not be.
Finally, if it is available, the second script is going to be executed
in the cli environment, not the web. This means the session_start()
will fail, as there is no web server involved (well, it may not fail -
but it won't do anything). And its output goes to stdout, (which is fed
back to the second parameter of exec(), which you are not using, so it
is thrown away), not to the web.
IOW, what you're trying to do is definitely not common, and probably not
the right way to go about things.
What is it you're really trying to do?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|