views:

17951

answers:

10

Hi, I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/

to install & config apache get the PHP5 packages and get the CURL packages.

I run the apache and run a PHP script. no problem. but when I run the php script with curl, it fails.

It returns: Call to undefined function curl_version() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing.php on line 5

In which line 5 is a called to curl_init()

I output the php -i to see whether the right path to extension is called. It is correctly set: extension_dir => C:\PHP\ext => C:\PHP\ext cURL support => enabled cURL Information => libcurl/7.16.0 OpenSSL/0.9.8g zlib/1.2.3

I even tried to run curl_version() but still, same kind of error comes up.
It looks like the PHP can't find the CURL extension, but the php.ini (and also php -i) shows that it is set.

any idea? :)

P.S> System I m running on: Windows XP Apache 2.2 PHP 5.2.6 CURL Win32 Generic Binaries: Win32 2000/XP metalink 7.19.0 binary SSL enabled Daniel Stenberg 249 KB

I didn't get this:
Win32 2000/XP 7.19.0 libcurl SSL enabled Günter Knauf 1.55 MB Should I get this one instead?

A: 

It's always best to try and find an answer to your problem, so you know in the future how to fix it. But I just want to say that I have been using wampserver for a while now and it's great. You can install and uninstall PHP extensions and apache modules with a click. You should check it out sometime.

Galen
A: 

I'm using XAMPP, in which there are several php.ini files.

You can find the line in the php.ini files: ;extension=php_curl.dll

Please remove ; at the beginning of this line. And you may need to restart apache server.

boxoft
A: 

The reason I need to use CURL is that it is the requirement from my project. So, I can only stick with that. XAMPP... how does it work in Windows? Is there any site that you can recommend? Thanks.

I have tried a lot of things on installing cURL and check everything, but still, I'm stilling circling around the problem and have no idea what's going on.

The Apache server uses the right PHP.ini. and the PHP.ini has the correct extension_dir and extension=php_curl.dll I have no idea why it doesn't work. even I follow every step for setting it up. :(

seatoskyhk
+6  A: 

You're probably mistaking what PHP.ini you need to edit. first, add a PHPinfo(); to a info.php, and run it from your browser.

Write down the PHP ini directory path you see in the variables list now! You will probably notice that it's different from your PHP-CLI ini file.

Enable the extension

You're done :-)

SchizoDuckie
I had this problem with the xampp installer package. It's directory tree structure is confusing to say the least. The php folder you fiddle with is rarely the correct one. phpinfo() is a fabulous trouble shooting tool. + 1 for this answer, - 1 for whoever designed the tree structure of xampp (which I'm guessing was the culprit in this instance).
Josh Smeaton
+1  A: 

You may find XAMPP at http://www.apachefriends.org/en/xampp.html

http://www.apachefriends.org/en/xampp-windows.html explains XMAPP for Windows.

Yes, there are 3 php.ini files after installation, one is for php4, one is for php5, and one is for apache. Please modify them accordingly.

boxoft
A: 

I solved the problem.

In my apache, I have to specify:

PHPIniDir "C://php" AddType application/x-httpd-php .php

and for php.ini, instead of using the php.ini_recommend, use php.ini_dist to configure my php.ini.

then make sure the php engine has turned on. then it works now. Thanks all.

seatoskyhk
A: 

Sorry to say that. but that's a BS to say "always best to try and find an answer to your problem". It is just like "Your mother is a female". I want some help from others, that's why I ask here.

General idea like that won't help. That's why I list my problem clearly and expecting specific answer. Some of them do, and I thank you for their suggestion. Some of them who don't, and I beg them not to BS to others.

seatoskyhk
It's very nice of you to explaining your problem and solution in detail. Thanks.
boxoft
+2  A: 

I recently installed Curl on PHP5 for Windows Vista. I did not enable the CURL library when I initially installed PHP5, so nothing about Curl was showing up in phpinfo() or php.ini.

I installed CURL by re-running the PHP5 installer (php-5.2.8-win32-installer.msi for me) and choosing "Change". Then, I added the CURL component. Restart Apache, and CURL should work. CURL will show up in phpinfo(). Also, here is a sample script you can run to verify it works. It displays an RSS feed from Google:

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,
    'http://news.google.com/news?hl=en&amp;topic=t&amp;output=rss');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $contents = curl_exec ($ch);
    echo $contents;
    curl_close ($ch);
    ?>
SpaceRook
A: 

s'il vous plait quel qu'un peu nou expliquer comment installer curl

A: 

Thanks SpaceRook, only your solution worked for me !