0

I am running PHP code with the following code invovled:

$ch = curl_init();

When I get to this line, the following error is returned:

Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\myfiles\API\IPVIKING_API.php on line 79

Now I've found all the answers talking about enabling the curl extension in the php.ini file, and I've done that, following this question here: How to enable curl in xampp?.

My problem is I do not have these 3 files:

C:\Program Files\xampp\apache\bin\php.ini
C:\Program Files\xampp\php\php.ini
C:\Program Files\xampp\php\php4\php.ini

I instead have 2 files called

C:\Program Files\xampp\php\php.ini-development
C:\Program Files\xampp\php\php.ini-production

I've uncommented the

;extension=php_curl.dll

line in both of them, restarted both my browser and xampp, yet it still gives me the same error. Suggestions?

Community
  • 1
  • 1
GK1667
  • 1,362
  • 3
  • 14
  • 22

4 Answers4

3

Make an

<?php phpinfo(); ?>

there you can see which php.ini is loaded. In this file you uncomment the the extension line.

When there is no php.ini in this path which is in the phpinfo this should be xampp/php/php.ini then rename one of the two files

C:\Program Files\xampp\php\php.ini-development

to

C:\Program Files\xampp\php\php.ini
René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • Thanks for your answer. I just did what you said, I restarted xampp and the browser, yet it still gives me the same error. Any other ideas? – GK1667 Jun 25 '12 at 14:43
  • Can you look in your phpinfo wheather the curl extension is loaded? – René Höhle Jun 25 '12 at 14:44
  • I'm unsure where exactly to look for this. On the xamp phpinfo() page, it has C:\xampp\php\php.ini as the loaded configuration file (which I commented out), and it has API20090626,TS,VC9 as the php extension builds. If its not one of these places, please let me know where I should be looking? – GK1667 Jun 25 '12 at 14:47
  • There is a complete section for curl. You can search for "cURL support" this should have the value "enabled" and you can look to your error log. (C:\xampp\apache\logs\error.log) perhaps there are some more informations. – René Höhle Jun 25 '12 at 14:48
  • I do not seem to have this section. I tried a search for just "curl" which gave no responses and then also "support", sifting through the support responses still nothing. – GK1667 Jun 25 '12 at 14:52
  • Then the curl module is not loaded. Then check the apache error logs. Perhaps you have a wrong version or something else. I have tried it here on my computer and its working well. And you could check wheather the php_curl.dll is in the php module folder. – René Höhle Jun 25 '12 at 14:58
  • got it! It required a complete system shut down. Thanks for sticking with me until I got it! – GK1667 Jun 25 '12 at 15:06
  • I had to add the following to my PHP code to get things to work: `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);` Maybe that's the issue. – HartleySan Oct 11 '16 at 14:51
2

You should move C:\Program Files\xampp\php\php.ini-production to C:\Program Files\xampp\php\php.ini.

rename "C:\Program Files\xampp\php\php.ini-production" "C:\Program Files\xampp\php\php.ini"

And then change:

;extension=php_curl.dll

to

extension=php_curl.dll

Then restart Apache.

Some systems require two files to be copied from where PHP is installed to your WINDOWS\System32 directory:

libeay32.dll
ssleay32.dll

Update:

copy "C:\Program Files\xampp\php\php.ini" "C:\xampp\php\php.ini"
Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • I have changed it. It's still giving the same error. Any other suggestions? – GK1667 Jun 25 '12 at 14:43
  • Have you restarted apache/xampp? – Mike Mackintosh Jun 25 '12 at 14:52
  • I've physically shut down xampp, and then restarted it. I figured apache would be included in that process. Is that untrue? – GK1667 Jun 25 '12 at 14:57
  • Depending on your OS, I have seen issues where restarting XAMPP does not restart the Apache service if you opted to install as a server. Go to Start, Run, type in `services.msc` look for apache and choose restart. – Mike Mackintosh Jun 25 '12 at 15:06
  • Also, look at the updated answer. Run the last command, `copy "C:\Program Files\xampp\php\php.ini" "C:\xampp\php\php.ini"` then restart apache, try again. – Mike Mackintosh Jun 25 '12 at 15:08
1

search for 'php.ini' file in

xampp\php\ directory

open php.ini

find for 'curl'

you will get line

;extension=php_curl.dll

uncomment it by removing semicolon at front of the line

extension=php_curl.dll

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
shyammakwana.me
  • 5,562
  • 2
  • 29
  • 50
0

There is a file named php (I think this is the real php.ini) with the type as configuration settings that is the one you need to uncomment extension = php_curl.dll. You should also uncomment the .ini-development and .ini-production. Restart and both browser and apache and it should work.

Nat Ritmeyer
  • 5,634
  • 8
  • 45
  • 58
Edwin
  • 1