I have IIS 10 and my program calls curl_init function to make API calls. But I get this error:
"Call to undefined function curl_init()" . Also when I look at the output of phpinfo() there is no cURL section showed up.
I've triple checked the php.ini file for extension=curl and ext folder for php_curl.dll. I also downloaded ssleay32.dll libeay32.dll files to system32 folder in C:. I restarted the server a couple of time. Still, when I check the phpinfo() there is no curl section there.
Here is what I have found in StackOverflow:
similar error
joshjdevl's answer may be the solution but what is the difference between thread-safe and non-thread-safe PHP package
Why does it work ?
about enabling curl extension here it is said that one should "add paths of your PHP directory to the Windows Environment PATH Variable for .dll dependencies." but in my local machine-my another machine-(with wampserver) I didn't add PHP to environment variables and it works, so do I really need to do that?
about making sure the system uses the correct php.ini file When I look at the phpinfo output I can see the path of the php.ini file. Based on that I assume IIS uses that php.ini file. I don't expect it to use another one.
about installing curl extension
I have searched more than 30 StackOverflow pages and still do not have a solution.
After 8 hours of search and tens of StackOverflow questions, I've finally added the PHP path to environment variables and in the output of phpinfo() method cURL section started being shown and the error disappeared.
Windows Start -> Edit the system environment variables -> Advanced -> Environment Variables -> New..
For a more detailed explanation and for screenshots
But still have no idea why it works properly even though I didn't add PHP paths to Environment variables in my local machine. I assume it may be about wampserver configurations.
Related
I have been a happy user of XAMPP for years,
but today I have updated to the latest Windows 32 bit version on a Windows 10 machine.
I couldn't see a 64 bit version.
Anyway, all went well,
and once I changed some settings, I was able to see all my old databases under the new phpMyAdmin.
But my PHP scripts are bombing out before they start.
Even phpinfo gives the same error message, which is...
"Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'F:/My Documents/OneDrive/Webs/htdocs/index.php'
(include_path='.;C:/xampp/php/pear/PEAR') in Unknown on line 0"
The test script of index.php is nothing more than
<?php echo "HELLO"; ?>
The statement in php.ini is
include_path = ".;C:/xampp/php/pear/PEAR"
and there are no other include_path statements.
The directory C:/xampp/php/pear/PEAR does exist.
The index.php file is there.
I don't know why there's a PEAR folder inside a pear folder - that's how Xampp installed it.
I have tried all variations of that include_path statement to no avail.
I have left out one of the pears.
Leaving out the include_path statement altogether just results in the PHP default which is a folder which is definitely not there, so that's no good.
My localhost is inside the OneDrive folder as you can see from the error message, but I have been doing it that way for years.
Now I cannot run any PHP scripts. Pure HTML is no problem.
The new installation of Xampp has totally replaced the old one, and its Control Panel v3.2.2 looks to be working perfectly.
phpMyAdmin seems to be working fine, but not phpinfo, as said.
I have scanned the web for answers to this, and there is plenty of forum Q&A's, but they all tell me to do what I have done.
The computer is Windows 10 Pro, and is fully up to date. Apache 2.4.33.
PHP 5.6.35. Database server is 10.1.31 MariaDB.
I've run out of ideas. Any help will be appreciated.
Thanks Mike.
You need to fix your include_path system variable to point to the correct location.
To fix it edit the php.ini file. In that file you will find a line that says, "include_path = ...". (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, "\xampplite\php\pear\PEAR" to read "C:\xampplite\php\pear". Make sure to leave the semi-colons before and/or after the line in place.
Restart PHP and you should be good to go. To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.
first: check all the paths in the php. ini ( use a search or a grep to check them)
second: check that you don't have any extensions added twice (one in the beginning and one in the end of the file)
WIN 10 Microsoft PC (not linux). I've installed PHP V 7.1.9.
Right now, i'm trying to install Curl. However I'm getting odd issues,
phpinfo :-
1) Curl is reporting an AUTHOR of Sterling Hughes, however no modules are active / found for curl.
So i'm guessing it knows the author - php knows curl is available ?
2) the file path for the Configuration File (php.ini) shows the path C:\WINDOWS, however Ive checked there & there is NO php.ini file located.
I have checked for hidden files too...
Ive got PHP installed in 2-3 other directories (i guess in one of the PATH directories, so thats why php is loading.)
QUERIES:
3) is there a php code to diagnose the true / correct pathname of where the php.ini is loaded from ? So i can edit it & uncomment the line about installing the curl dll file.
(I have those lines uncommented in the php.ini files I could find).
4) Is there a way in a php script to "load" up Curl if its not in the php.ini file ?
(ive downloaded CURL in a ZIP file & extracted the files).
all the examples so far refer to php.ini, but no examples of PHP code to activate / load up Curl from within a php script itself without being installed via the php.ini file.
Retrieve PHP.ini path: You can try with PHP functions. php_info() or php_ini_loaded_file()
http://php.net/manual/en/function.phpinfo.php
http://php.net/manual/en/function.php-ini-loaded-file.php
Way to load up CURL dynamically ?
You can't. There was a function to achieve it but had been removed.
http://php.net/dl
To install Curl, follow the instruction below
http://php.net/manual/en/curl.installation.php
Similar question(Very helpful):
PHP and CURL under Windows 7 64 bits and Apache
Before I begin, I will add that I've spent much time googling this and have attempted several solutions none of which have worked.
System Info:
Windows 7 Professional (x86, 32 bit )
Apache2 up and running C:\Program Files\Apache Software Foundation\Apache2.2\
PHP 5.3.8 C:\Program Files\PHP Also works.
manually configured httpd.conf to enable php, note that php is working, except for curl.
I have enabled curl in my php.ini C:\Program Files\PHP\php.ini
This is near the end of my php.ini
[PHP]
extension_dir = "ext"
[PHP_CURL]
extension=php_curl.dll
Note also that the file C:\Program Files\PHP\ext\php_curl.dll exists!
I have restarted the apache server and yet curl still does not function.
a quick test.php file:
<?php
$curl_conn = curl_init();
?>
note that I have both php start and end tags correct stackoverflow just isn't showing the start php tag.
puts out:
Fatal error: Call to undefined function curl_init() in E:\path\to_project\test.php on line 3
I have now spent 3 hours trying to get curl to work, google has no helped, most of the solutions seem to involve making sure that the extension=module line in php.ini is not commented out, and as you can see above it is not commented out so that advice doesn't seem to help me.
Any ideas would be appreciated as this is rather frustrating.
Thanks!
You should add "C:\PHP" to the server's PATH environment variable:
Right-click on My Computer, choose Properties
Flip to the Advanced tab
Click the Environment Variables button
Double-click the Path variable in the list of System variables.
Either add "C:\PHP;" to the beginning or ";C:\PHP" to the end (sans quotes, not both).
Restart your computer for it to take effect.
Thanks to:
http://www.webcheatsheet.com/PHP/install_and_configure.php
I know this thread has long been closed, but for anyone like myself who encounters this problem subsequently, for me, the answer turned out to be a DIFFERENT copy of the php.ini file was being loaded than what I thought. I was editing the php.ini file in my PHP 5.4.3 directory, and there is another copy of the php.ini file that resides in the Apache directory - identical as far as I could tell from a quick glance.
De-commenting the extension=php_curl.dll line IN THE RIGHT FILE, the Apache folder, enabled the curl function for me.
Jeff S.
Have you copied cURL dependency files:
libeay32.dll
ssleay32.dll
to C:\Windows\System32 folder?
It could be that PHP cannot find these two files to run cURL extension.
I am using the Xampp server with php5 . I have been trying to get the curl extension working. But, unable to do it. I uncommented the php_curl.dll line in php.ini. I dont see curl enabled in phpinfo() . I also copied the ssleay32.dll and libeay32.dll files to both syswow64 and system32 directories. Do i have to install anything on the server? Has anyone used xampp server before with curl ? thanks
To be honest I did not used XAMPP but couple of times I've faced problems with WAMP extensions on Windows.
Almost always reason was one of the following:
There aren't required file in /ext directory,
Extension line in php.ini is commented,
I forgot to restart server.
Also, this looks interesting (from link #1 below):
There’s a straight-forward XAMPP FAQ
Entry about their php.ini stucture.
For those looking for the easy fix,
ignore everything but the
/apache/bin/php.ini file. That’s the
only one that counts, regardless of
which PHP version you’re currently
using.
What about all the .dll files you
need? Well, you don’t need them.
Everything you need to run CURL on a
XAMPP install is included in the
download. Stop downloading extra crap
and sticking it all over your system.
XAMPP knows what it needs, where it’s
at, and how to use it. End of story.
If above steps doesn't help, read following articles (and comments):
Using CURL in XAMPP
Enable CURL with XAMPP on Windows XP
Enable Curl on Xampp
Getting cURL to Work in XAMPP
Be aware of multiple php.ini files in XAMPP. Be sure that you have edited right one.
P.S. I've just tried to enable cURL in Wamp/XP. I've removed leading semicolon ; from line ;extension=php_curl.dll and restarted server. Now I can see cURL support: enabled in phpinfo() page. I guess that's easy in XAMPP too.
I just installed Apache 2.2.15/PHP 5.3.2/MySQL 5.1.44 on Windows Vista. Apache is working fine, PHP is functional, and MySQL works on the CLI. However, when I try to access MySQL via PHP, I get an error (Fatal error: Call to undefined function mysql_connect()). extension=php_mysql.dll and extension=php_mbstring.dll are uncommented in the php.ini file, and PHP is in the system path. There is no libmysql.dll in either the top level PHP directory or the ext directory. There's a libmySQL.dll file in the MySQL bin directory (which is also in the system path); I tried renaming it, but that doesn't do anything
Also, in case anyone wants to know, I originally installed PHP using the MSI installer, but it was missing some DLLs, so I installed from the zip file.
I think I've exhausted all my options. Any help on this problem would be very appreciated.
Thanks in advance.
IIRC the msi installer sets some registry values that influence the php configuration, see http://docs.php.net/configuration.changes#configuration.changes.windows. That might change the location of the php.ini that is used. You might want to delete those registry keys. Anyway, you did edit the file that is shown in the output of phpinfo()?
Which build of php do you use? The one you can download from http://windows.php.net/download/? Then you probably have the new mysqlnd transport driver built into the php core dll and don't need libmysql.dll. The mysqlnd driver should show up in the output of phpinfo(). Does it?
It sounds like you do not have the MySQL mod for PHP properly installed or configured. I recommend using AMP on Linux, so sorry for not having any specific instructions for Windows.