Results 1 to 7 of 7

Thread: Problem calling php from include

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Problem calling php from include

    Where is the file who.php? is it in the same folder as welcome.php?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow 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 !

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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 :-(

  6. #6
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width