Can you believe php -m says yes and phpinfo() says no? - php

This is my php.ini
extension_dir = "ext"
extension=php_tidy.dll
[Tidy]
;tidy.default_config = /usr/local/lib/php/default.tcfg
tidy.clean_output = Off
Can you belive when I type php -m, I get tidy in the list but when I check the phpinfo() function, there is no mention about tidy ?
And when I write $tidy = new tidy; in a php file, I get this error Fatal error: Class 'tidy' not found in E:\DEV\WWW\lexique\load.php on line 32. (The application worked fine under a previous install)
PHP 5.4.15
Apache 2.4

CLI and Apache environments use seperate php.ini configs. As such they separately define the extensions they use.
php_tidy will have to be enabled on both configurations to work.
This depends on your setup however. I am using a Ubuntu install as an example which typically contains both directories /etc/php5/apache2 and /etc/php5/cli, each containing their own php.ini file.
The extensions themselves however are usually shared, so you shouldn't need to install them twice.

I have resolved it adding the PHP folder to the PATH and restarting the computer.

Related

How to enable the PDO MySQL extension on Windows? [duplicate]

I have installed PHP 7 on windows 10 to my E: drive so I can try out composer.
When I try to run composer I get an error that it can't find the extensions I enabled but I can see it is looking in C:\php\ext and not E:\php\ext.
I looked in php.ini but couldn't see whre to set the path of the root installation.
Does it always default to C:? How do I tell it to look in E:?
For some reason, PHP for Windows is hardwired to look for extensions in C:\php\ext no matter where you installed it. But there's a simple fix for this.
In your php.ini, look for the line extension_dir =. If it's disabled (as a comment), enable it.
You only need to mention the name of the folder where the extensions reside if this folder is inside your PHP installation folder. An absolute path is not necessary.
extension_dir = "ext"
Open a Command Prompt and run php -a to check if PHP complains about missing extensions. If not, you're doing good.
Regarding the answer above, using extension_dir = ".\ext" in the php.ini (Check php --ini) a relative path also works.

cURL is enabled in php.ini but still not working

I have enabled the cURL extention in he php.ini folder, I have copied mutliple dll files from the PHP folder into the Apache Bin folder and the System 32 folder but cURL is still not enabled on my system.
All the solutions that I have looked at:
How to enable cURL in PHP / XAMPP
http://php.net/manual/en/curl.installation.php
http://php.net/manual/en/curl.installation.php#115953
http://php.net/manual/en/curl.installation.php#117372
I know this because I still see the following error:
Fatal error: Call to undefined function curl_init() in C:\AMP\sites\ftp-crawl\index.php on line 55
When I run only phpinfo(), there are no cUrl options. The only mention of cURL is under module authors and its value is cURL: Sterling Hughes
I am running a windows 10 developer machine with PHP, MySQL and Apache installed.
What do I still need to do or check to enable curl?
I had the same problem. I fix it replacing the php_curl.dll. Maybe a file corruption.
In php.ini I setup with extension=php_curl.dll.
No more Call to undefined function curl_init() errors.
I resolved the issue by editing my PHP.ini to include the full path of the extension as opposed to just the name.
So where most php.ini files just have this line of code:
extension=php_curl.dll
I changed it to look like this:
extension=C:\amp\PHP\ext\php_curl.dll
I have no idea why PHP/Apache couldn't show an error while I had extension=php_curl.dll in my php.ini. At least saying something like dll missing or something like that, but that resolved my issue.
I believe you edited the demo or wrong php.ini file.
In your phpinfo you will find a path to the used php.ini file. It's next to the text: "Configuration File". Check out that file and make sure that the following option is set (by default it is commented out with a semicolon).
extension=php_curl.dll
If you can not find this line, you might have a different version of Apache. In this case you might find a directory called "mods-available" in which the curl extension lays. You need to move this file to the "mods-enabled" folder. Honestly I think this only applies to Linux environments, not sure about Windows.
It means that the curl module is not installed on the server. This problem generally occurs with php5. You need to check if php5-curl module is installed or not. Also confirm if curl is installed on the system.
Terminal command curl -v.

Call to undefined function pg_escape_string() [duplicate]

I am trying to connect to my database (remote server) which has PostgreSQL installed in it. My PHP code is trying to connect to the database using pg_connect(), but I get the error saying:- "Fatal error: Call to undefined function pg_connect() in /var/www/website/functions.php on line 82".
The line 82 simply is:
$db = pg_connect($conn_string);
where $conn_string = "host=".$hostname." port=5432 dbname=".$dbname." user=".$db_user." password=".$db_password.""
(all variables defined earlier)
I checked many forums and the only solution suggested was locating the php.ini file which contains a line:- extension = pgsql.so (for UNIX) and extension = php_pgsql.dll (for Windows).
This statement is supposed to be commented and the solution is to uncomment it. I have tried it but still does not change the situation. The remote server has a version later than PostgreSQL v9.0.4 installed.
I then installed PostgreSQL v8.4.8 on to my laptop and ran the website locally using MAMP. At first, Apache crashed for some odd reason, I fixed that problem but again I ended up with the same error as before i.e. Fatal error: Call to undefined function pg_connect()....
I also ran the phpinfo() and it showed that the php version does support the PostgreSQL module.I have spent an entire day searching for the solution but have been unsuccessful. This is my first project developing a website and I am out of wits. Any kinda help will be highly appreciated.
phpinfo() gives me a huge list of things at the terminal but the listings relevant to PostgreSQL are as follows:-
pdo_pgsql
PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 9.0.4
Module version => 1.0.2
Revision => $Id: pdo_pgsql.c 306939 2011-01-01 02:19:59Z felipe $
pgsql
PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 9.0.4
Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited
I had restarted MAMP after every edit I made since it was mentioned in every post I have read so far. I believe that resets both Apache and php.
'pqsql.so' (which is the UNIX equivalent of 'php_pqsql.dll' in Windows) is present in the 'extension' directory. I also copy-pasted the 'pqsql.so' file on to the Apache/bin directory but it did not give me any change.
I am not running php in the command line primarily. I just was curious to see what phpinfo() would give me relevant to pgsql which I have mentioned in my reply above.
I am still working on the tools you have mentioned and will respond as soon as I get any results.
Thanks,
H
You need to install the php-pgsql package or whatever it's called for your platform. Which I don't think you said by the way.
On Ubuntu and Debian:
sudo apt-get install php-pgsql
Easy install for ubuntu:
Just run:
sudo apt-get install php5-pgsql
then
sudo service apache2 restart //restart apache
or
Uncomment the following in php.ini by removing the ;
;extension=php_pgsql.dll
then restart apache
Fatal error: Call to undefined function pg_connect()...
I had this error when I was installing Lampp or xampp in Archlinux,
The solution was edit the php.ini, it is located in /opt/lampp/etc/php.ini
then find this line and uncomment
extension="pgsql.so"
then restart the server apache with xampp and test...
Edit. I just noticed you were mentionning MAMP. My advice is for Windows but may be useful if you know what corresponding tools to use.
Things to try:
Have you restarted PHP and Apache since your editing of php.ini?
Is the php_pgsql.dll found in your php\ext directory?
Are you running php as a module? If so, try copying the php_pgsql.dll
file in the Apache\bin directory.
Are you running PHP from the command line with a flag specifying a
different php.ini file?
You could try using a tool such as Sysinternals' Filemon to view what
files are attempting to be accessed when running PHP.
You could try using a tool such as Dependency Walker to look at the dependencies for the postgreSQL DLL, in case you have a missing dependency. Quick search brought up ldd for Unix.
Add 'PHPIniDir "C:/php"' into the httpd.conf file.(provided
you have your PHP saved in C:, or else give the location where PHP
is saved.)
Uncomment following 'extension=php_pgsql.dll' in
php.ini file
Uncomment ';extension_dir = "ext"' in php.ini
directory
I had the same symptom in win7. I got this script:
<?php
phpinfo();
pg_connect("blah");
When I executed the phpinfo.php script via apache (http://localhost/phpinfo.php) then I got the error message:
Call to undefined function pg_connect() in...
When I executed the same script from command line (php phpinfo.php) then I got the expected message:
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: missing "=" after "blah"
In both cases the expected php.ini was used:
Loaded Configuration File C:\Program Files (x86)\php\php.ini
but the pgsql section was completely missing from the phpinfo in case of the apache-based execution and it was present in the command-line-based execution.
The solution was that I added the following line to the apache httpd.conf:
LoadFile "C:/Program Files (x86)/php/libpq.dll"
It seems that for some reason this file is not loaded automatically when apache runs the php script but it is loaded if I run the php script from the command line.
I hope it helps.
You have to follow these steps:
Open the php configuration file, which is located in the following directory
C: \ xampp \ php \ php.ini
Within that file search the extension section and uncomment the following lines
extension = php_pdo_pgsql.dll
extension = php_pgsql.dll
and restart your apache
I also had this problem on OSX. The solution was uncommenting the extension = pgsql.so in php.ini.default and deleting the .default suffix, since the file php.ini was not there.
If you are using XAMPP, the php.ini file resides in /XAMPP/xampfiles/etc
install the package needed.
if you use yum:
yum search pgsql
then look at the result and find anything that is something like 'php-pgsql' or something like that. copy the name and then:
yum install *paste the name of the package here*
For php 5.4 on Centos 6.10, we include these lines in php.ini
extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo.so
extension=/opt/remi/php54/root/usr/lib64/php/modules/pgsql.so
extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo_pgsql.so
It works.
I encountered this error and it ended up being related to how PHP's extension_dir was loading.
If upon printing out phpinfo() you find that under the PDO header PDO drivers is set to no value, you may want to check that you are successfully loading your extension directory as detailed in this post:
https://stackoverflow.com/a/14786808/2578505
On Gentoo, use USE flag postgres in /etc/portage/make.conf and re emerge "emerge php"
Uncommenting extension=php_pgsql.dll in the php.ini configuration files does work but, you may have to also restart your XAMPP server to finally get it working. I had to do this.
The solution has to do with the fact that your the file holding your php configurations. i.e php.ini has uncommented the extension responsible for acting as the middleman between php and postgres, by placing a ";" in front of the statement "extension=pdo_pgsql"
Quick Fix
Open the php.ini file in your favourite editor. (atom 🙌)
Search for the line "extension=pdo_pgsql", which is under the "Dynamic Extensions" section. (a simple ctrl + f) would get you there quick.
Remove the ";" in front of the line ";extension=pdo_pgsql".
Restart your server.
Go fix more errors like a rock star. 👍
If you got php5.6 using the ppa repository http://ppa.launchpad.net/ondrej/php/ubuntu,
then you should install the package using:
sudo apt install php5.6-pgsql
Finally, if you use apache2, restart it:
sudo service apache2 restart
For those of you who have this problem with PHP 5.6, you can use the following command:
yum install php56w-pgsql
For a list of more package names for PHP 5.6, open the following link and scroll down to packages:
PHP 5.6 on CentOS/RHEL 7.0 and 6.6 via Yum
In windows OS find this in php.ini "php_pgsql.dll" and remove the ";" in the extension then that's it :) Cheeers!

PMA error : mbstring is missing

I am running on Windows 7 64 bit with:
Apache 2.2
PHP 5.2.8
MySQL 5.1 (essentials)
installed and configured manually. As you all know, for this since MySQL essentials has no GUI for interaction the best suit is PhpMyAdmin. I am trying to get phpMyAdmin-4.0.10.8-english, downloaded from the PMA website, into my Apache web server.
After all configuration work, now I get an error message when I try to log into PMA saying:
"The mbstring extension is missing. Please check your PHP
configuration."
In this forum it was mentioned that possible causes for this are the unavailability of php_mbstring.dll in php folder or else the extension_dir variable in php.ini is set to ./ which is the current folder.
I checked in the ext folder and the .dll file is available and the extension_dir variable is set to ./ext. And I tried setting the variable to C:/php/ext which is the absolute location, still it doesn't work. Any help on this concern would be much appreciated!
Probably the mbstring extension is just not activated in php.ini. Look for the line
;extension mbstring = php_mbstring.dll
and remove the leading ;
Also make sure that you are looking at the correct php.ini since there could be more than one in your installation.

Call to undefined function curl_init() error in wamp 2.2

I am having below error when I try to implement google and facebook authentication in windows 7 using wamp server.
Fatal error: Call to undefined function curl_init() in
E:\wamp\www\mysite\protected\extensions\eauth\EAuthServiceBase.php
on line 273
I am using,
wampserver 2.2
php version 5.3.13
I have enabled php_curl module as well. I checked in php.ini for confirm and it is uncommented as below.
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
The code has worked in ubuntu with xampp, but not in wamp in windows. I have done everything I can find. I have tried replacing the php_curl.dll also according to the comment on this thread, Call to undefined function curl_init() - with WAMP
My phpinfo() looks like below.
I have installed wamp in the partition E:\, but the "Configuration File (php.ini) Path" seems different, it is C:\Windows.
Please help me to fix the issue.
Visit this and have a file under Fixed curl extensions:
http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/
after download and replace related file then restart server.
In browser navigate to localhost and make sure there is curl extensions showing under Loaded Extensions :
For WAMP running PHP 5.4.3 on Windows 7 64 bit, make sure you use php_curl-5.4.3-VC9-x64.zip NOT php_curl-5.4.3-nts-VC9-x64.zip.
In windows 7 with PHP 5.5.31 after check that php_curl.dll extension is enabled (and still doesnt working), work for me to copy libeay32.dll and libssh2.dll from php directory to Apache bin.
just a guess - this section in php.ini does not reference the correct location
; Directory in which the loadable extensions (modules) reside.
extension_dir = *some value*
http://www.php.net/manual/en/ini.core.php#ini.extension-dir
edit
Also, look for this block in your phpinfo, if it's not there, curl isn't loading (obviously). You're not looking for matching version numbers - just for the block's existence.
edit
look at this question also
PHP and CURL under Windows 7 64 bits and Apache
When using WAMP..
You should have one file php.ini in the main PHP directory
In the php.ini enable the extension extension=php_curl.dll, by removing the ; char
The extension_dir must look like this example: extension_dir = "D:\AMP\PHP\ext\", so not a relative path
You need to restart Apache server only once. No need to restart it many times
Just make sure, you have the php_curl.dll in the ext directory
(windows 10 user)
Since this is the first result in Google and I had exactly the same problem and none of your solutions worked for me and I finally find the correct solution in an other thread of stackoverflow, I'll post link here :
EasyPHP Devserver 16.1 Curl Win 10
The solution is to add the your current PHP directory (depend of which version you use) to your global "path" variable in windows (like explained in the link, but you don't need to add all php directorias of course)
Not sure where to put my experience, hope it will be useful for someone.
In my case (win7 x64 + apache 2.4 + php 7.2), curl extension was enabled in php.ini but did not load. Resolved by replacing libs libssl-1_1-x64.dll and libcrypto-1_1-x64.dll in Apache's bin folder with the latest builds of OpenSSL
For those running PHP 7+ on windows, there is no php.ini file in the php directory by default.
You need to:
create a php.ini file in your PHP directory (it should be under C:\php\, or wherever your php directory is located)
Copy the content of either php.ini-development or php.ini-production into the php.ini file you've created.
Finally remove the semicolon (;) before extension=curl
Change the extention in php.ini file uncomment by removing ; like below
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
Then restart all services and it will work.

Categories