Page 1 of 1

execute an external script within a script

Posted: Fri Oct 27, 2006 5:59 am
by ansa
Hi,

I have a script, let's say myscript.php.

In myscript.php, I want to execute an external script with its parameters, let's say:

http://www.otherserver.com/external.php?var1=a&var2=b

I have tried include() and exec() for this, but didn't work.

Is there a way to do this? Thanks for any hint!

Re: execute an external script within a script

Posted: Fri Oct 27, 2006 6:18 am
by volka
ansa wrote:I have tried include() and exec() for this, but didn't work.
If it didn't work you probably got an error message. If not try again with

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', true);
at the beginning of your php script.

Posted: Fri Oct 27, 2006 8:24 am
by ansa
Which function should work with this, include() or exec()?

With exec(), I don't get any error message. The page acts as if nothing happened. With include(), I also don't get any error message. The script in the link just does not work the way I want it. Because this is an external link, I can not do any debugging.

But if I copy the link (http://www.otherserver.com/external.php?var1=a&var2=b) onto the browser and run it, it works just fine.

Wondering why...

Posted: Fri Oct 27, 2006 11:20 am
by feyd
Including a file from a remote site is highly dangerous. file_get_contents() or fsockopen(), et al should work depending on your server's settings.