Call to undefined function http_get()

Discussion in 'PHP' started by yaramhu, Oct 20, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I use http_get function in my php code. When I tr to run the php page on browser I get the next message :
    Fatal error: Call to undefined function http_get()
    But when I run my php script from command line there isn't any error message and it works fine.
    Can somebody help what would be the problem ?
     
    yaramhu, Oct 20, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    The function needs to be available within the script. Include() it if it's in another file.
     
    nico_swd, Oct 20, 2007 IP
  3. yaramhu

    yaramhu Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The function http_get() is in the php script, there isn't other php page.
     
    yaramhu, Oct 20, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Hmm... can you post your code?
     
    nico_swd, Oct 20, 2007 IP
  5. yaramhu

    yaramhu Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here it is. It just get a xml from a server. From command line I get the xml as result.

    <?php
    echo "Start";

    $keres = http_get("https://x.x.x.x/reports.asp" , array("httpauth" => "user:password"));
    $valasz_body = http_parse_message($keres)->body;
    echo $valasz_body;
    echo "End";



    ?>
     
    yaramhu, Oct 20, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    That's what I meant, neither the http_get() nor http_parse_message() functions are defined. These are not built-in functions.

    Where are these functions defined? Include() this file.
     
    nico_swd, Oct 20, 2007 IP
  7. yaramhu

    yaramhu Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    http_get() is in the php_http.dll extension.
    But as I mentioned, from command prompt the script works correctly so knows this function. Would be the Web server (Apache) faulty maybe ?
     
    yaramhu, Oct 20, 2007 IP
  8. satusaja

    satusaja Active Member

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #8
    check phpinfo if the extension is enabled
    maybe your apache can't find the correct php.ini
     
    satusaja, Oct 20, 2007 IP
  9. yaramhu

    yaramhu Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The problem is resolved.
    I noticed on the apache error log this message : Unable to load dynamic library php_http.dll - the specified modul could not be found.
    However the php_http.dll was the right directory and the setting of the extension_dir was right too.
    I tried to reinstall apache but it didn't help. I spent a lot of hours to find solution on the web and it seems hundreds and hundreds noticed this bug too but I couldn't find any solution.
    I used Apsserv 2.5.8 (l tried 2.5.9 too) package with PHP 5.2.3 and Apache 2.2.4. At the and I unistalled Appserv and downloaded PHP 5.2.4 and Apache 2.2.4. After the installation my script worked perfectly.
     
    yaramhu, Oct 20, 2007 IP
  10. MetaCipher

    MetaCipher Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    MetaCipher, Oct 22, 2007 IP
Thread Status:
Not open for further replies.