cURL undefined function curl_init()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamesm
Forum Newbie
Posts: 6
Joined: Sun Aug 18, 2002 1:47 am
Location: UK

cURL undefined function curl_init()

Post by jamesm »

Using phpinfo() I have half way down my list of features:

CURL support enabled
CURL Information libcurl 7.9 (OpenSSL 0.9.6b)

I run the script:

$ch=curl_init('https://www.anysite.asp');
;and go on set curl opts
$submit="some data";
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$submit);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$data=curl_exec($ch);
if (!data){
die(sprintf('Error [%d]: %s',curl_errno($ch),curl_error($ch)));
}


;and receive a fatal error in Zend development Environment of
Call to undefined function: curl_init() in <b>C:\Apache Group\Apache2\htdocs\myfile.php

In a browser this reads:

Notice: Use of undefined constant data - assumed 'data' in C:\Apache Group\Apache2\htdocs\myfile.php on line 28

It does actually perform the transfer, and I receive a stream of data back.

Am I being stupid (this is my first attempt at php) or is the curl entension not correctly installed. (or perhaps both)?
Thanks
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Make sure the functions you are using are included in the CURL version you have installed?

-Aaron
jamesm
Forum Newbie
Posts: 6
Joined: Sun Aug 18, 2002 1:47 am
Location: UK

Post by jamesm »

Thanks for the reply,

Yes its the latest version of cURL.

Any more ideas?
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Well, easier things first, the notice on line 28 comes because you should have if(!$data) instead of if(!data).
The curl_init error could be coming from Zend Studio not recognizing the curl extension, perhaps? try eliminating the $data error, then see if it works in a browser (or in the CLI, if that's what you're writing it for). If it does, but still doesn't work in Zend, then you've got to figure out how to enable curl support in zend.
Post Reply