Unable to load curl for PHP 5, apache & XP

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Unable to load curl for PHP 5, apache & XP

Postby raghavan20 » Tue Jan 23, 2007 6:05 am

I get the following error when i ran a CURL based script
Syntax: [ Download ] [ Hide ]
Fatal error: Call to undefined function curl_init() in C:\Program Files\Apache Group\Apache2\htdocs\TestIT.php on line 8


i have done the following as of now

1. in php.ini in c:/windows

Syntax: [ Download ] [ Hide ]
;extension=php_mbstring.dll
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll



2. in windows path
Syntax: [ Download ] [ Hide ]
C:\Documents and Settings\Master Wenly>path
PATH=c:\windows;c:\windows\system32;c:\windows\System32\Wbem;c:\program files\ph
p\libeay32.dll;c:\program files\php\ssleay32.dll;c:\program files\php



3. i have also copied ssleay32.dll and libeay32.dll to c:/windows and c:/windows/system32

I still cannot load cURL. any ideas? Thanks.

EDIT:
I also have another doubt.
when i changed php.ini extension setting from
Syntax: [ Download ] [ Hide ]
extension_dir = ".\ext"


to absolute path,
Syntax: [ Download ] [ Hide ]
extension_dir = "c:\program files\php\ext"


the apache started giving up error
Syntax: [ Download ] [ Hide ]
The application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby feyd » Tue Jan 23, 2007 8:31 am

Restarted Apache? Verified the php.ini you edited is the one loading?

get_cfg_var() or phpinfo() can provide the php.ini path information.
[feyd:蜘龍] - Jon | Forum Tour | Useful Posts
Most Helpful '05, '06; Best Code Snippet '05; IATM '06, '07; Best Avatar '07; | SHA256
You will be ignored if you contact me privately about code I did not write or support.
User avatar
feyd
Neighborhood Spidermoddy
 
Posts: 31559
Joined: Mon Mar 29, 2004 4:24 pm
Location: Germantown, Tennessee, USA

Postby raghavan20 » Tue Jan 23, 2007 8:57 am

feyd wrote:Restarted Apache? Verified the php.ini you edited is the one loading?

get_cfg_var() or phpinfo() can provide the php.ini path information.


thanks feyd for your reply

from phpinfo()
Syntax: [ Download ] [ Hide ]
Configuration File (php.ini) Path  C:\WINDOWS\php.ini


apache has been restarted many times already.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby volka » Tue Jan 23, 2007 9:27 am

please run
Syntax: [ Download ] [ Hide ]
<?php

$inifile = get_cfg_var('cfg_file_path');



if ( false==$inifile ) {

        die('no config file');

}



if ( false==($cfg=file($inifile)) ) {

        die('canot read config file');

}



$extdir = get_cfg_var('extension_dir');

$extdir = str_replace('\\', '/', $extdir);

if( '/'!==substr($extdir,1, -1)) {

        $extdir .= '/';

}



echo 'ini: ', $inifile, "<br />\n";

echo 'ext: ', $extdir, "<br />\n";



$pattern = '!^\s*extension\s*=\s*(\S+)!';

foreach($cfg as $p) {

        if ( preg_match($pattern, $p, $m) ) {

                echo $m[1], ' # ', $extdir.$m[1], ' # ', file_exists($extdir.$m[1]) ? 'ok':'error', "<br />\n";

        }

}

?>
and post the output.
User avatar
volka
DevNet Evangelist
 
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Postby raghavan20 » Tue Jan 23, 2007 9:33 am

Syntax: [ Download ] [ Hide ]
ini: C:\WINDOWS\php.ini
ext: ./ext/
php_curl.dll # ./ext/php_curl.dll # error
php_mysql.dll # ./ext/php_mysql.dll # error
php_mysqli.dll # ./ext/php_mysqli.dll # error
php_xsl.dll # ./ext/php_xsl.dll # error


i could say these are the ones i enabled in php.ini file.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby raghavan20 » Tue Jan 23, 2007 10:04 am

fyi

php installation directory: c:/program files/php
apache installation directory: c:/program files/Apache Group


Thanks.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby volka » Tue Jan 23, 2007 10:37 am

open C:\WINDOWS\php.ini in a text editor
find extension_dir
set extension_dir = "c:/program files/php/ext/"
save file, restart apache
try again.
User avatar
volka
DevNet Evangelist
 
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Postby raghavan20 » Tue Jan 23, 2007 10:53 am

volka wrote:open C:\WINDOWS\php.ini in a text editor
find extension_dir
set extension_dir = "c:/program files/php/ext/"
save file, restart apache
try again.


Great, Curl is working but I have a few problems as below.

i tried that but it comes up with this error
Syntax: [ Download ] [ Hide ]
The application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem


but still the apache ran.


i ran your script and this is the output
Syntax: [ Download ] [ Hide ]
ini: C:\WINDOWS\php.ini
ext: c:/program files/php/ext//
php_curl.dll # c:/program files/php/ext//php_curl.dll # ok
php_mysql.dll # c:/program files/php/ext//php_mysql.dll # ok
php_mysqli.dll # c:/program files/php/ext//php_mysqli.dll # ok
php_xsl.dll # c:/program files/php/ext//php_xsl.dll # ok


Thanks for your help.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby raghavan20 » Tue Jan 23, 2007 12:31 pm

i copied this file, libmysql.dll to apache installation directory and restarted apache and everything is working without error.
i dont really know why apache cannot recognize those files from php installation directory.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby volka » Tue Jan 23, 2007 11:38 pm

Has to do with the way windows searches for dlls, see http://forums.devnetwork.net/viewtopic.php?t=62010
You now have
http://msdn2.microsoft.com/en-US/library/ms682586.aspx wrote:1. The directory from which the application loaded.
User avatar
volka
DevNet Evangelist
 
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Postby raghavan20 » Mon Jan 29, 2007 4:11 am

on monday morning, i wanted to make a change to a cURL application and comes with this error
Syntax: [ Download ] [ Hide ]
Fatal error: Call to undefined function curl_init() in C:\Program Files\Apache Group\Apache2\htdocs\TestIT.php on line 8


and when i checked from where php.ini is loaded, it is from
Syntax: [ Download ] [ Hide ]
Configuration File (php.ini) Path  C:\Program Files\PHP\php.ini


can you guys tell me where should I change setting so that it picks up php.ini from c:/windows ? I checked httpd.conf but I cannot find any line in there specifying the location of php.ini file

Thanks.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby feyd » Mon Jan 29, 2007 9:42 am

If you're running Apache2, you can set the PHPIniDir directive in httpd.conf. Alternately, you could delete the php.ini it is finding in Program Files.
[feyd:蜘龍] - Jon | Forum Tour | Useful Posts
Most Helpful '05, '06; Best Code Snippet '05; IATM '06, '07; Best Avatar '07; | SHA256
You will be ignored if you contact me privately about code I did not write or support.
User avatar
feyd
Neighborhood Spidermoddy
 
Posts: 31559
Joined: Mon Mar 29, 2004 4:24 pm
Location: Germantown, Tennessee, USA

Postby raghavan20 » Mon Jan 29, 2007 11:17 am

it works now.

i am running apache 2.2 even though i used apache 2 dll for php to run the PHP.
i could not find any phpIniDir setting inside httpd.conf in apache-install-dir/conf/

i then deleted the file in c:/program files/php which is the php-install-dir then it picked up file from c:/windows.

why is this happening feyd?

thanks for your reply.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK

Postby feyd » Mon Jan 29, 2007 11:19 am

PHP and Windows will use the php.ini found first. Windows will search in the current directory of the executable first before looking in the PATH.
[feyd:蜘龍] - Jon | Forum Tour | Useful Posts
Most Helpful '05, '06; Best Code Snippet '05; IATM '06, '07; Best Avatar '07; | SHA256
You will be ignored if you contact me privately about code I did not write or support.
User avatar
feyd
Neighborhood Spidermoddy
 
Posts: 31559
Joined: Mon Mar 29, 2004 4:24 pm
Location: Germantown, Tennessee, USA

Postby raghavan20 » Mon Jan 29, 2007 11:20 am

oh good. that is logical even though that is not our expected behaviour.
User avatar
raghavan20
DevNet Resident
 
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK


Return to Installation and Configuration

Who is online

Users browsing this forum: No registered users and 1 guest