stevieontario Posted May 12, 2009 Share Posted May 12, 2009 Morning php Freaks: I'm playing in a sandbox (xampp) and testing some code (php 5.2. containing the function curl_init. A very rudimentary version of my web app is running, successfully, using curl_init() at one point. But when I test my code in my test environment using the identical function, I get the following error: Fatal error: Call to undefined function curl_init() in C:\Program Files\xampp\htdocs\dev\Functions1.php on line 100 Anybody have any ideas what's going on? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/ Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 Can we see the relevant code? Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832372 Share on other sites More sharing options...
redarrow Posted May 12, 2009 Share Posted May 12, 2009 curl not loaded cheek. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832374 Share on other sites More sharing options...
GingerRobot Posted May 12, 2009 Share Posted May 12, 2009 This probably means the cURL library is not installed. If you run a page with just this in: <?php php_info(); ?> You'll be able to verify this. If you cannot find a section called curl/libcurl, then it is not installed. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832376 Share on other sites More sharing options...
stevieontario Posted May 12, 2009 Author Share Posted May 12, 2009 Thanks maq. Here's the relevant code: function curl_string($url,$user_agent,$proxy=0) { $ch = curl_init(); //curl_setopt ($ch, CURLOPT_PROXY, $proxy); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832377 Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 Looks right to me, did you have the library installed, like Ben said? Here's how you can check: This probably means the cURL library is not installed. If you run a page with just this in: php_info(); ?> You'll be able to verify this. If you cannot find a section called curl/libcurl, then it is not installed. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832382 Share on other sites More sharing options...
thebadbad Posted May 12, 2009 Share Posted May 12, 2009 Like redarrow says, cURL isn't loaded/enabled on the server. To enable it, stop the server via the XAMPP control panel, then open the relevant php.ini file (mine's located in XAMPP/apache/bin/php.ini), and remove the semi-colon appearing before extension=php_curl.dll (around halfway through the file). Start your server again, and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832385 Share on other sites More sharing options...
stevieontario Posted May 12, 2009 Author Share Posted May 12, 2009 thanks badbad and everyone else, I'm not a Windows expert, and I suspect the following subsequent problem has to do with Windows. I "found" the file you refer to (xampp/apache/bin/php.ini) but not by navigating to the folder. When I navigated to the folder I couldn't see a file called "php.ini" or any text file called "php." Rather, I "found" php.ini it using the Windows search feature, which indicated that php.ini is in the referenced folder. I also found the relevant line and made the recommended change. But couldn't save it (I guess Search puts everything into a temp folder). So I just navigated to xampp/apache/bin and saved it from Notepad. This created a new file (i.e., didn't overwrite the existing one). So the code still won't execute. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832421 Share on other sites More sharing options...
thebadbad Posted May 12, 2009 Share Posted May 12, 2009 Strange that you can't see the file. Maybe it's hidden? But it's not on my machine (running Vista). And I can't see why you shouldn't be able to edit the one you found through a search (I'm perfectly able to). It could also be that the server is using another php.ini file (there are several within the XAMPP folder; I once had a hard time finding the relevant one) - in that case you could try to edit all the php.ini files you can find, and see if it works. Apache must be using one of them Also: What do you mean you "couldn't save it"? Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832497 Share on other sites More sharing options...
stevieontario Posted May 12, 2009 Author Share Posted May 12, 2009 badbad, Actually, the message says I cannot "create" the file. I found more than one "php.ini" when I did a search, and was able to make your recommended change and save it. But there are two others whose search results do not indicate a path beginning with "C://". I cannot save those two others; I get the message: Cannot create the C:// etc temporary directory. Weirdness! I tried attaching a screenshot showing the error message, but it got rejected. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832512 Share on other sites More sharing options...
PFMaBiSmAd Posted May 12, 2009 Share Posted May 12, 2009 The xampp documentation tells you which php.ini is used for the web based php and the cli php. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832513 Share on other sites More sharing options...
thebadbad Posted May 12, 2009 Share Posted May 12, 2009 Ah, documentation, clever idea It says XAMPP/apache/bin/php.ini is the right file, so you should be able to find it. Have you turned on the setting to display hidden files? Not that it should be hidden though. Maybe you need administrative rights to edit the file - try running Notepad as administrator (if you're using Vista). Edit: And remember to restart the Apache server after editing the file. Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832520 Share on other sites More sharing options...
GingerRobot Posted May 12, 2009 Share Posted May 12, 2009 The xampp documentation tells you which php.ini is used for the web based php and the cli php. As will the output of php_info() Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832526 Share on other sites More sharing options...
stevieontario Posted May 12, 2009 Author Share Posted May 12, 2009 well as it turns out the only php.ini file I was able to change was the right one. phpinfo() now indicates curl is enabled, by god! Thanks for your time, everyone -- much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/157819-solved-problem-with-curl_init-fatal-error/#findComment-832546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.