Hello

I've got those files on my serv (for example)
001.html
002.html
main.html
index.php

#---------index.php content----------#

$action=getenv(query_string);
if ($action == '"') { include ("main.html"); }
else { include ($action.".html"); }

#---------index.php content end----------#

After I run index.php?001 there's an error in line 3.
How to deal with?

Thanks

    Originally posted by magician

    if ($action == '"') { include ("main.html"); }
    else { include ($action.".html"); }

    Hi,
    your problem is this. The php parser, even with if(), will includes both, "main.html" and $action.".html".

    Change your code in:

     
    if ($action == '"') $action="main";
    
    include ($action.".html"); 
    

    This will works, I think.

    bye bye

      $action=getenv(query_string);
      if ($action == '"') { include ("main.html"); }
      else { include ($action.".html"); } 
      
      1. the test $action=='"' fails because it's not an empty string - you wrote ' " ' ...

      2. php will NOT try to include both...

      3. weedpacket is right - read the thread

      4. what does this error you get look like?

        • perhaps you receive something like:
          'main(): Failed opening '001.html' for inclusion (include_path='.: ...
          in that case check you include-settings in php.ini

        what does this error you get look like?
        - perhaps you receive something like:
        'main(): Failed opening '001.html' for inclusion (include_path='.: ...
        in that case check you include-settings in php.ini

        You're right with above error message.

        I'll read the tread, thanks for now.

          you can set the include-path in php.ini
          or in your program like this:

          // set additional path before inclusion:
          $otherpath ="/web/includes";
          $phppath   = ini_get("include_path");
          // add more paths separated by ':'
          $phppath  .=":".$otherpath;
          ini_set("include_path",$phppath);
          

            Okay.

            I've read the topic and everything seem to be ok.

            DonChris: I include file from my root cat and it works even without paths in php.ini, i tried to include file using http://mysite.com/included_file.php and it works too.

            thanx

              Write a Reply...