|
Resource Center
: PHP
: <php unable to load dynamic library. or, undefined function domxml_new_doc() called .. kind of errors>
|
|
php unable to load dynamic library. or, undefined function domxml_new_doc() called .. kind of errors
Posted by: Floresense Team
If you are running php on windows with apache, you would probably have gotten here because of problems with using functions like domxml_new_doc().
many functions exist in separate libraries in the extension (on php4) or ext (on php5) folder. and on windows you get the errors because you either havent market the required extension in the php.ini file and mapped to apache, .. or , you did that and apache threw 'library not found' error while starting up.
Typically, you should have the php.ini file in your php directory ex: c:/php4/php.ini and should have mappend the the location of this file in apache httpd.conf file with the below line
PHPIniDir "c:/php4"
Once you have that in place, go to php.ini file and check what all extensions are enabled. You can search for extensions and you will find a list of extensions like below
extension=php_bz2.dll extension=php_cpdf.dll extension=php_crack.dll extension=php_curl.dll ... ...
if after mapping php.ini location in apache httpd.conf file and after restarting apache, you get any errors saying a dll or extension was not found, you can comment the line for the dll like below in php.ini file, and restart apache again.
;extension=php_curl.dll
if you have added ; and disabled loading of an extension like php_domxml.dll then you will not be able to use XML DOM related functions in your php code. it will just say undefined function name.
now a core reason for a dll being present and still apache saying dll not found .. is because.. a dependency of that dll is not present. For example my xml dom code didnt work and i found out that iconv.dll which was not there in the extensions directory was a dependency of php_domxml.dll and so apache kept saying "dll not found". I then copied iconv.dll from c:php4 to c:php4extensions and also to c:windowssystem32 and then things worked fine.
INI file A typical ini file i use is attached...in case you are confused with kind of settings you should use for your php. Mine is php4.3.0 on apache2 on windows xp prof, and i have disabled all extensions that i dont need for my work in the php.ini file. you can tweak them as per your needs.
Similar problem with PHP_mysql(/i).dll extension: When setting up php_mysql.dll extension for php5, on windows, similar problem occurs.. Using windows dependency walker its easily found out that windows is unable to load phpTS.dll and libmysql.dll on which php_mysql(i).dll depends
Copying phpTS.dll and libmysql.dll to /ext directory (of php5 install location)... also copying libmysql.dll to windows/system32 directory, and restarting webserver, solved the problem.
Better off, instead of copying files to windows/system32, you can always keep the files in your php directories itself, and tell windows that it has to search your php directories also for dependencies rather than just windows/system32 folder (which is what happens in windows by default).
To tell windows, add the PHP folder path(not the extensions directory path) to the PATH environment variable. To do that you will have to right click on MyComputer, select 'Properties', then 'Advanced settings', then 'Environment variables'.. and in the set of environment variables, select PATH and click edit. In the dialog that opens, the current setting of the PATH variable is found.. don't mess with it, just add your php folder path like below.
Existing PATH setting:
%SystemRoot%system32;%SystemRoot%;
Add PHP path to the end.
%SystemRoot%system32;%SystemRoot%;C:php5;
Any change to the environment variable requires the system to reboot to take effect.. So, restart your windows system.
Advertisement
|