Running a script in CLI I receive this error:
PHP Fatal error: Call to undefined function mb_detect_encoding() <script path/name here>
Some background.
PHP 5.3.10 (cli) (built: Feb 2 2012 20:27:51)
Running Windows 7 (call it a work constraint) with MySQL and Apache2.2 (both currently functional)
I understand this function is part of the module php_mbstring.dll
I will attempt an exhaustive list of efforts to get this loaded:
Verified php.ini location; phpinfo indicates the loaded file is in
c:\php; the configuration file is in c:\windows (two locations - both
have an identical .ini file)
The php.ini files have uncommented extension=php_mbstring.dll
The extension directory is specified in both php.ini files as
extension_dir = "c:\php\ext"
the specified file (php_mbstring.dll) is in fact present in the specified directory c:\php\ext\php_mbstring.dll
Although I cannot see why this would be effective, I have moved the dll to both the php root as well as windows32 directories as seen on other forums
I do have other functional non-core modules (e.g. mysqli) loaded in the same way without issue
It may be worth noting that upon uncommenting the extension line in the loaded config file (c:\php\php.ini), an additional system error of "can't start because php5.dll is missing from your computer" appears as a dialogue box. I have tried uncommenting in both and in either one and get the same error.
I suspect there is a way to load this module without recompiling or reinstalling PHP.
Related
I have been fighting this problem for 2 days now and can't seem to solve it.
I installed Apache on my computer and am running as localhost. I do not have SSL but have tried with and without loading openssl extension.
If I start the Apache 24 Service from "Windows Services" PHP works but no extension dlls will be loaded, specifically I'm trying to load cURL. If I stop the "Windows Services" and run httpd from a command prompt all of the extensions load just fine.
Interestingly enough all PHP functionality works fine except the extensions when running from the "Windows Services".
The event log shows the following when I first start the "Apache Windows Service":
php[29280]
PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl' (tried: ext\php_curl (The specified module could not be found.), ext\php_php_curl.dll (The specified module could not be found.)) (D:\Apache24\bin\httpd.exe -d D:/Apache24)
The only real clue I have found in the phpinfo is the difference I see between the "Windows Service" and the Command Line httpd is:
"Windows Service"
"Command Line httpd"
My php.ini file has the following settings for cURL:
extension_dir = "ext"
extension=curl
extension=openssl
PHP Info Screen Shots:
Common to Both
Using command line "httpd"
Using Windows Service (Note cURL is missing and event log shows the error mentioned above)
I also noticed the "Configuration File (php.ini) Path" is set to "C:\Windows" so I tried copying the php.ini file to c:\windows and copied the ext folder containing all of the dlls to C:\Windows as well but still had the exact same problem. I have since removed the php.ini and ext folder from C:\Windows to avoid any future path problems.
Does anyone have any idea what I'm missing?
Define the path of the extention directory to full path from
extension_dir = "ext"
to
extension_dir = "c:\PHP7.4.7\ext"
So i'm trying to use the PDO module in PHP on a Redhat based distribution (RHEL7) to interact with a database.
In my Php script i have the 'use PDO;' directive, but in the PHP log i get an error : PHP Fatal error: Uncaught Error: Class 'PDO' not found in ...
The extension is uncommented in the php.ini file (extension = pdo.so), i have tried with the relative and the absolute path. I even reinstalled the php-pdo package (yum install), but without success.
I've compared my phpinfo() with a working phpinfo(), and i am missing the PDO section.
I have checked and Apache loads the correct php.ini file
I've passed all my extensions permissions to 755 just to be sure.
I don't get any php warning at startup so i don't know where the problem seems to be.
I found the error :
First i started using php in direct command line, and set the env' variable LD_DEBUG=libs:
./php -c /path/to/php.ini /path/to/php/file.php
So with that i was able to get the debug on the dynamic loading of my modules and on the php.ini.
I saw that there was an uncommented line that was blocking the loading of the modules in the INI file, then you have to load the mysql.so module before the pdo_mysql.so and of course restart you apache server.
I'm trying to use php threads but I receive this message when I run my file in the console: Unable to load dynamic library 'php_pthreads.dll' (tried: c:/wamp64/bin/php/php7.2.10/ext/php_pthreads.dll and if I open it on my localhost it shows the error Class thread not found.
I'am using wamp server, I have Windows 10 64 bits.
I use php version 7.2.10
I downloaded the php threads dlls from here: https://windows.php.net/downloads/pecl/snaps/pthreads/3.1.6/
I already put the phtreadVC2.dll in the folder C:\wamp64\bin\php\php7.2.10,
the php_phtreads.dll in C:\wamp64\bin\php\php7.2.10\ext
And edited the php.ini file in C:\wamp64\bin\php\php7.2.10
and I even tried editing the php.ini file located in C:wamp64\bin\apache.
In my phpinfo() I have enabled Thread Safety
And I have the compiler: MSVC15 (Visual C++ 2017)
I have not actually used this extension but can I suggest you try these changes to what you have done.
Putting the php_pthreads.dll into c:/wamp64/bin/php/php7.2.10/ext/ sounds correct.
However, you should try putting phtreadVC2.dll into C:/wamp64/bin/apache/apachex.y.z/bin where x.y.z is the version of Apache that you are using. This is where PHP under Apache will probably look for this DLL.
If you might want to use php_pthreads.dll under the PHP CLI then also edit C:/wamp64/bin/php/php7.2.10/php.ini and add the extension= parmeter in here as well as this is where the CLI will probably look for it.
Now to make sure you are adding the extension into the correct php.ini that PHP under Apache will find its php.ini us the menus on wampmanager. Thats the green W icon in the System Tray by doing
left click wampmanager -> PHP -> php.ini
This should open the editor on the correct php.ini file, the one that controls PHP when used under Apache. Add the extension into here.
If you want to use the CLI, then you will also have to make the same edits to the php.ini file in c:/wamp64/bin/phpx.y.z/php.ini this is the php.ini that controls what the PHP CLI loads.
Restart Apache once you have made all these changes and see how it goes.
I have been away from PHP for quite a while, so hopefully this is a simple oversight. But, I am not able to include the MySQL extension.
Setup
Windows 8 Pro 64-bit
NetBeans 7.2.1 (Built-in PHP Web Server)
MySQL
PHP 5.4.8
Problem
Fatal error: Call to undefined function mysql_connect()
Attempted Resolution
Copy php.ini-development to php.ini (files are where I installed PHP, E:\Software\php-5.4.8-Win32-VC9-x86)
Edit php.ini by uncommenting the lines
extension_dir = "ext"
extension=php_mysqli.dll
Added E:\Software\php-5.4.8-Win32-VC9-x86\ext to NetBeans PHP Include Path in Project Properties
Still fails with the same error
Diagnostic Output
Added a call to phpinfo() at the top of the page. That indicates:
Configuration File (php.ini) Path C:\Windows
However, there is no php.ini in C:\Windows. In fact, I searched all disks and found only the one php.ini file that I previously edited.
Question
Where is NetBeans / PHP pulling the configuration from when I run my project, and how can I edit that configuration?
Restart the web server/netbeans :-)
If there's no php.ini file listed as being loaded by phpinfo() then there is not one. PHP will use default values for everything in this case. Anything that needs to be overridden can be placed in a new php.ini in one of the locations specified by phpinfo() as being scanned for ini files.
From your description what you did to php.ini (excerpt):
extension=php_mysqli.dll
^
But in your question you write:
Fatal error: Call to undefined function mysql_connect()
Which is a different extension, namely on windows:
extension=php_mysql.dll
(without the i)
Probably it's just a little oversight you're missing here. You have two options then:
Port the code to mysqli_* functions (recommended for new code)
Activate the old php_mysql.dll extension (for legacy code)
Do what fit's your needs. On windows, the folloing filenames (search your disk) are interesting:
php.ini - normally inside the directory where you find php.exe
php_mysql.dll - normally inside the ext subdirectory of the just said directory.
This is becoming a very frustrating issue. I am trying to do a clean install of apache 2.2 and PHP 5.2.11. Everything seems to be configured correctly but the php modules aren't starting...
PHP Warning: PHP Startup: Unable to load dynamic library '.;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ext/php_mcrypt.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '.;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ext/php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '.;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ext/php_openssl.dll' - The specified module could not be found.\r\n in Unknown on line 0
in the php.ini
include_path = ".;C:\Program Files (x86)\Apache Software Foundation\Apache2.2\php"
extension_dir = ".;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ext/"
All the files are there... The .dll files such as ssleay32.dll, libmcrypt.dll, libmysql.dll, libeay32.dll are all installed at...
C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/
I also included them in the C:\Windows\System32
and even added C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ to the windows path.
I have no idea why this isn't working and it feels like a no win situation. Anyone have any ideas on how to get this all working ok?
Try this:
extension_dir = "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/php/ext/"
without starting with the .;
You just uncomment the extension_dir in php.ini
Just for my future self if no-else. This is with PHP 5.2.13 running in Windows on IIS 8.
I got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_openssl.dll' - The specified module could not be found.
From phpinfo() the loaded php.ini file was C:\Program Files (x86)\PHP\php.ini.
The extension directory:
extension_dir ="C:\Program Files (x86)\PHP\ext"
These were the last two lines of the php.ini file:
[PHP_SQLSRV]
extension=php_sqlsrv_52_nts_vc6.dll
[PHP_OPENSSL]
extension=php_openssl.dll
The php_openssl.dll and php_sqlsrv_52_nts_vc6.dll files are in the ext directory. The php_openssl.dll isn't corrupt (it's the same file size as one on another machine that's working).
PHP will find the sqlsrv dll but not the openssl dll. No idea why. No amounts of IIS restarting did anything.
The solution until I know better was to install the openssl.dll extension using the Windows PHP installer. You can re-run the installer and select 'Change' and it allows you to add or remove libraries. I can't see any difference in the file or the php.ini file now, but now the file loads.
I suspect actually that my problem was similar to this comment about OpenSSL installation on Windows:
At this point, when you start Apache it will attempt to load php_openssl.dll, but if your setup is anything like mine you will see an error. I prefer to start Apache manually, and the error appears in a dialog box: "The ordinal 4114 could not be located in the dynamic link library LIBEAY32.dll". (I'm not sure whether you would get this message if you started Apache as a service). The Apache log also contains an error message saying that php_openssl.dll cannot be loaded, though that message doesn't name libeay32.dll. Welcome to DLL Hell.
Libeay32.dll enters the picture because php_openssl.dll depends on it (and also on ssleay32.dll). What I think happens is that Apache first tries to load php_openssl.dll programmatically from the path specified by the extension_dir key. But then, the loading of the so-called dependent DLLs is left to Windows' default mechanism. If Windows finds an incompatible version of a dependent DLL, you get the error.
I noticed errors about ssleay32.dll when trying to run php -i from the command line. I just assumed that it didn't have it in the environment. IIS made no mention of any ssleay32.dll errors in its logs.
Had same errors, but instead of copying files added php folder to system path and restated the server.
Windows 8.1 have a bib problem with system PATH names what cannot editable with the general editor because this line is too long......and for PHP module extension good loading must to define PHP path in the system enviroments.
ONLY one thing helped for me:
https://rix0rrr.github.io/WindowsPathEditor/