Script Not working - PHP version problem - maybe?

Discussion in 'PHP' started by rj87uk, May 21, 2007.

  1. #1
    Hey All,

    I have a script that works fine on PHP Version 4.4.2 however on PHP Version 5.2.0 it doesnt work. When I click this link:

    http://www.blah.co.uk/city-Glasgow.html I get this error:

    
    Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/tho10000/public_html/blah/index.php on line 10
    
    Warning: include(http://www.blah.co.uk/city.php?id=Glasgow) [function.include]: failed to open stream: no suitable wrapper could be found in /home/tho10000/public_html/blah/index.php on line 10
    
    Warning: include() [function.include]: Failed opening 'http://www.blah.co.uk/city.php?id=Glasgow' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tho10000/public_html/blah/index.php on line 10
    
    HTML:
    The page displays ok when i use this URL:
    http://www.blah.co.uk/city.php?id=Glasgow

    So I think it may have something to do with Mod Rewrite or Something to do with the change in PHP Version.

    Has anyone got any clues?
     
    rj87uk, May 21, 2007 IP
  2. lemaitre

    lemaitre Peon

    Messages:
    61
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The first warning has your answer. When it says url-file access is disabled, that means statements like

    include ("http://www.example.com/stuff.html");
    PHP:
    where the file argument is a URL, are not allowed. You will have to use curl for this, or ask your host to enable URLs in includes.
     
    lemaitre, May 21, 2007 IP
    rj87uk likes this.
  3. rj87uk

    rj87uk Active Member

    Messages:
    283
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Ok - I will Email the host.

    I thought the use of include files were normal and that just about everyone uses them?

    Thanks!
     
    rj87uk, May 21, 2007 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    They are, but you're not using them the way that most people use them. When you include via HTTP you are including the OUTPUT of the already parsed script.

    Most people include them via the filesystem so as to include the actual PHP code.
     
    TwistMyArm, May 21, 2007 IP
    rj87uk likes this.
  5. Free Directory

    Free Directory Peon

    Messages:
    89
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Most for sure, it's a PHP5 issue, relate of the include for full website path.
    But's in the php file, you can check that line (number 10) and set proper inclusion (without full url)

    --- OLD, but might help ---
    tip: just try using that way:
    script it's in the root folder .
    include ("city.php?id=Glasgow"); Relative paths
    if it's not working, do a trick, by checking the id variable (you send it in request) as a 'global' variable, like that:
    $include_id="Glasgow";
    include("city.php");


    and do a if case in the city.php, just before you extract the $_REQUEST['id']:
    if (strlen($include_id)>0) 
    {
      $current_id=$include_id; //or whatever you need it to be, it will contain Glasgow
    } 
    else 
    {
      $current_id=$_GET['id'];
    }
    
    Code (markup):
    then, all should work as expected.
    Note: if you're using the id from GET, and you evaluate it in a function ( the above if sentence) be sure you set a global $current_id; before that sentence (top of the function.
     
    Free Directory, May 21, 2007 IP
    rj87uk likes this.
  6. rj87uk

    rj87uk Active Member

    Messages:
    283
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Hey All,

    Just to update you it is a URL include problem and my host says they are not going to change it and i will need a work around.

    Free Directory - heh, I am at a beginner level at PHP - I have attached the "index" file that then goes onto include "city.php".

    Its rather complicated?
     

    Attached Files:

    rj87uk, May 22, 2007 IP
  7. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Tip, is this maybe what you want to achieve?
    $handle = fopen ("http://www.example.com/", "r");
    echo $handle;
    PHP:
    If not ...
    Could you use cURL?
    To check this, use this:
    <?php
    if (!extension_loaded('curl')) {
        if (!dl('curl.so')) {
            die("cURL is not loaded");    
    }else{
    die("cURL is not loaded but could be loaded");
    }
    }else{
    die("cURL cannot be loaded");
    }
    ?>
    PHP:
    Save it as a file and access via your browser. Let me know the result.
     
    DeViAnThans3, May 22, 2007 IP
  8. rj87uk

    rj87uk Active Member

    Messages:
    283
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Hey,

    The result was - "cURL cannot be loaded".

    Also that code gave me an error - wasn't too sure how to use it tho...?

    I tried:

    	
    $handle = fopen ("city.php?id=".$params[0]), "r");
    echo $handle;
    
    PHP:
    Hmmf!
     
    rj87uk, May 22, 2007 IP
  9. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #9
    rj87uk: is there a particular reason you're including via HTTP? Do you want to include the CODE within that file or include the OUTPUT of that file?

    If you want to include the CODE, you're doing it wrong, anyway. As I said (and as Free Directory demonstrated) earlier, you need to include it via the filesystem.

    If you actually do want to include the OUTPUT, your host is obviously very tight about HTTP connections and so you would have to do it some other way (for example, include the file via the filesystem and call a function to render the file).
     
    TwistMyArm, May 22, 2007 IP
  10. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #10
    If you use fopen(), you must specify the full url - including http:// ;)
     
    DeViAnThans3, May 22, 2007 IP
  11. rj87uk

    rj87uk Active Member

    Messages:
    283
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #11
    Yeah - Looks like I want to include the output, as its not the normal way i would include a file. I never wrote the script it was a PHP programmer.

    I tried contacting the guy but his emails are not working - what a jam eh?
     
    rj87uk, May 22, 2007 IP
  12. Free Directory

    Free Directory Peon

    Messages:
    89
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #12
    let's go that way:
    1: backup your old index.php
    2: add
    $config['scripturl']=dirname(__FILE__);
    Code (markup):
    right under include("config.php");
    3: replace
    include($config['scripturl']."city.php?id=".$params[0]);
    Code (markup):
    with that lines:
    $id=$params[0];
    $_GET['id']=$params[0];/*only if the first one does not work. I don't have the city.php code*/
    include($config['scripturl']."city.php");
    
    Code (markup):
    4: If that works, do the same for the agency.php.

    Enjoy.
     
    Free Directory, May 22, 2007 IP
  13. rj87uk

    rj87uk Active Member

    Messages:
    283
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #13
    Hey.

    My GOD you are my HERO, Seriously.

    Yep! I agree - A Life saver at that!!

    ---

    For the agency to work i added in this:

    
    $id=$params[1];
    $_GET['id']=$params[1]; /*only if the first one does not work. I don't have the city.php code*/
    include($config['scripturl']."/agency.php");
    
    PHP:
    Thank you So much :D
     
    rj87uk, May 22, 2007 IP
  14. Free Directory

    Free Directory Peon

    Messages:
    89
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Thanks... whoopsie... i blushed:)
    Glad that i could help you.
    Enjoy!

    PS: yes, you added exactly what was needed;)
     
    Free Directory, May 22, 2007 IP