ghgarcia Posted August 24, 2007 Share Posted August 24, 2007 I have a need to call another php application from within another php application and pass it parameters with a value returned. I have attempted to use include but to no avail. Any help would be greatly appreciated. Thanks, George Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/ Share on other sites More sharing options...
micmania1 Posted August 24, 2007 Share Posted August 24, 2007 Post the script if this doesnt help. If you want to use the variables from the included file you need to use global. <?php include "file.php"; global $variable1, $variable2; // variables set in file.php ?> Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333576 Share on other sites More sharing options...
ghgarcia Posted August 25, 2007 Author Share Posted August 25, 2007 My include statement is the following: include ("emailpicks.php?week=$week&user=$user"); The error that I get is: Warning: main(emailpicks.php?week=5&user=ghgarcia) [function.main]: failed to open stream: No such file or directory in /usr/local/4admin/apache/vhosts/lvbash.com/httpdocs/football/entry.php on line 168 The php app emailpicks.php does exist not sure what this error means. Thanks, George Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333596 Share on other sites More sharing options...
trq Posted August 25, 2007 Share Posted August 25, 2007 Read the man on include. You can't pass variables via the url unless you use a full domain name and have url_wrappers enabled. Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333598 Share on other sites More sharing options...
micmania1 Posted August 25, 2007 Share Posted August 25, 2007 <?php // Don't listen to what i say ?> Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333600 Share on other sites More sharing options...
trq Posted August 25, 2007 Share Posted August 25, 2007 Didn't you just post that same answer? Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333603 Share on other sites More sharing options...
micmania1 Posted August 25, 2007 Share Posted August 25, 2007 Sorry, I'm just trying to help. Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333607 Share on other sites More sharing options...
XaeroDegreaz Posted August 25, 2007 Share Posted August 25, 2007 Try this... $week = $week; $user = $user; include ("emailpicks.php"); But you shouldn't need to do that. If $week and $user are already defined in your main script, and in your include script it is expecting these variables, then they will already be available. You DON'T need to call any globals. The variables can be accessed no matter what. //File1.php $a = "Hi!"; //File2.php include("File1.php"); echo($a); //Outputs "Hi!" So that means... //File1.php $week = 36; $user = "XaeroDegreaz"; include("emailpicks.php"); //emailpicks.php echo("Week: $week / User $user"); //Outputs the stuff. Just ensure that you have already defined the variable contents before you call the include. Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333608 Share on other sites More sharing options...
ghgarcia Posted August 25, 2007 Author Share Posted August 25, 2007 Try this... $week = $week; $user = $user; include ("emailpicks.php"); But you shouldn't need to do that. If $week and $user are already defined in your main script, and in your include script it is expecting these variables, then they will already be available. You DON'T need to call any globals. The variables can be accessed no matter what. Just ensure that you have already defined the variable contents before you call the include. That did the trick thanks. Really appreciate the help. George Link to comment https://forums.phpfreaks.com/topic/66588-calling-external-application/#findComment-333626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.