Problem calling php from include
I wonder how i can call the following link using include( "); . I tried the following and it gives me error :
include("who.php?action=who");
Error :
Code:
Warning: main(./who.php?action=who) [function.main]: failed to open stream: Invalid argument in c:\myserver\www\whoisonline2\welcome.php on line 2
Warning: main() [function.include]: Failed opening './who.php?action=who' for inclusion (include_path='.;C:\php5\pear') in c:\myserver\www\whoisonline2\welcome.php on line 2
Fatal error: Call to undefined function track() in c:\myserver\www\whoisonline2\welcome.php on line 4
but when i type who.php?action=who in browser it works well and it executes the who.php for me but it does not work when i use it in include. I be happy if some one tell me how to fix this problem.Thanks
Re: Problem calling php from include
Where is the file who.php? is it in the same folder as welcome.php?
Re: Problem calling php from include
Quote:
Originally Posted by john tindell
Where is the file who.php? is it in the same folder as welcome.php?
Thank u for u reply. Yes it is in the same folder as welcome page !
Re: Problem calling php from include
try removing the '?action=who' from the include. I'm not 100% sure about this but PHP could be literally looking for a file which is called "who.php?action=who" which doesn't exist. Is the '?action=who' nessesary? Does it have a perticular function?
Re: Problem calling php from include
Quote:
Originally Posted by john tindell
try removing the '?action=who' from the include. I'm not 100% sure about this but PHP could be literally looking for a file which is called "who.php?action=who" which doesn't exist. Is the '?action=who' nessesary? Does it have a perticular function?
well the funciton who has doing lots of stuff and if i remove the action i get blank white page .The function needs to print out number of users are currently online :-(
Re: Problem calling php from include
well it'll only work if the ?action=who is in the browser's address box. At least thats what i think.
Re: Problem calling php from include
Using include is like takeing the code in the file and copying and pasting it into the postition which inlcude was called. The include statement does cause PHP to jump out of PHP mode into HTML mode though:
include.php
PHP Code:
<?php
echo('hello');
?>
This code:
PHP Code:
<?php
echo('moo');
include('include.php');
?>
Would translae too this once the file has been included:
PHP Code:
<?php
echo('moo');
?>
<?php
echo('hello');
?>
<?php
?>
You cannot pass variables via the query string in the include statemnet, because the code inherits the variable scope of the current line. You can therefore access all variables you would be able to access from the script, form the include file.