Fatal error: Call to undefined function printer_open() - php

I'm trying to print some string using PHP, i'm using the PHP print functions:
$printer = ("HP LaserJet Professional P1102");
$handler= printer_open($printer);
$content="Test Content";
printer_write($handler, $content);
printer_close($handler);
but I got that error :
Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\print.php on line 12
after googling it i found that i must add the php_printer.dll to the extensions file in php and add it's extension to the php.ini file, then restarting the server services, all of that accomplished but still getting that error.
p.s. I've tried it on WAMP and XAMPP

I think solution would be extension location.php_printer extension should be stored in c:\xampp\php\ext and not in c:\xampp\php. So move it to the ext-folder, and restart Apache.
Can you look into the error_log, which tells you, if it fails to load the module. You should also run a phpinfo(), which shows up all loaded modules, you must find the printer extensions there.
I hope it may resolve your issue.

Related

PHP: mysqli extension doesn't load

I try to use MySQL with PHP and I have this error:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in 'file_name Stack trace: #0 {main} thrown in 'file_name'`
When doing print_r( get_defined_functions()), I see that the MySQLi extension isn't there, but it is "loaded" in the php.ini file (I mean this is not in a commentary).
I specify that the PHP directory is in the PATH (I'm under windows) and MySQL, PHP and Apache are on my C: disk.
I don't know where is the problem, this is probably a small thing but I can't see which one so.
My versions are:
Apache 2.4.47
PHP 7.1.7
MySQL 5.7
Windows 7
PS : php_mysqli.dll do only 97k. I don't know if it's normal.
HOW I SOLVED THIS : I have just added extension_dir="path_to_php\ext" under the lines who load extentions, in the php.ini file. This line is used to indicate where are the extentions in your hard disk. Don't forget to restart your server, it will reload the php.ini file.
First of all, run phpinfo() to make sure you are looking at the correct php.ini.
If your php.ini file has extension=php_mysqli.dll uncommented check your extension directory. You may need to set it explicitly, like:
extension_dir="C:\xampp\php\ext"
If the problem persists check the apache error log, you should find more info there.

Call to undefined function curl_init() in wampp

I am getting an error. I have done the following:
Find file php.ini and uncomment in wamp apache folder
Find file php.ini and uncomment in wamp php folder
checked in wamp extensions
download file and replace php_curl-5.3.13-nts-VC9-x64.zip
restart wamp.
But I still get error
Fatal error: Call to undefined function curl_init() in C:\wamp\www\wordpress\wp-content\plugins\test\curl_http_client.php on line 66
Call to undefined function curl_init
You either edit wrong php.ini file or something is missing on your system, preventing curl extension from loading. You shall check with phpinfo() where is proper php.ini, then check if you got extension entry for cURL really enabled. If so and it is still not working then next step should be checking Apache's error.log looking for detailed error messages from PHP.

Fatal Error: Call to undefined function gzopen() when installing WordPress theme

I'm seeing the below error after attempting to activate a WordPress theme. The error message in the browser is...
Fatal error: Call to undefined function gzopen() in /var/www/mysite.com/wp-content/themes/flat/themify/themify-builder/classes/class-themify-builder-layouts.php on line 528
Checking my /var/log/apache2/error.log I see the following error:
Call to undefined function gzopen() in /var/www/mywebsite.com/wp- content/themes/flat/themify/themify-builder/classes/class-themify-builder-layouts.php on line 528, referer: http://mywebsite.com/wp-admin/update.php?action=upload-theme
Server information:
OS: Ubuntu 14.04 LTS
Apache: APache/2.4.7
PHP: PHP 5.5.9-1ubuntu4
That happened with me too (after upgrading to 14.04 #ubuntu). I waisted my whole day on it but in the end i found the solution.
replace gzopen with gzopen64.
this absolutely worked for me.
PS: I'll like the magento community to know that this problems appeared in creating package, after upgrading apache and php.
This issue occurs because your PHP server is not compiled with Zlib (this PHP module allows you to read and write .gz compressed files). Zlib support in PHP is not enabled by default.
More information about how to setup Zlip can be found here: http://php.net/manual/en/zlib.setup.php

phpwebsocket - Undefined Function socket_create() - Have php_sockets enabled on Windows/WAMP

I checked out the PhpWebSockets project from here:
https://code.google.com/p/phpwebsocket/
It's in its own project on my localhost (Windows 7 64-bit) box, inside of a WAMP server. I issue the following command in Windows Command Line to run the server.php file:
C:\wamp\bin\php\php5.4.12\php.exe C:\wamp\www\phpwebsocket\server.php
But it results in the following error message:
PHP Fatal error: Call to undefined function socket_create() in C:\wamp\www\phpwebsocket\server.php on line 58
My WAMP instance DOES have the php_sockets extension enabled (since I saw this similar question who had that problem).
Anyone know what I could possibly be doing wrong?
Found the answer in another thread:
Error with PHP Websocket and Wamp Server
Turns out running the file on the command line means it uses a different php.ini file than the WAMP server does. Seems stupid, but turned out php_sockets wasn't uncommented in that php.ini file, and removing it removed the error with it.

"unable to load dynamic library" Errors when running PHP from command line

When I try to run my script I at first I put the shebang in the script at the top and then tried this:
php -f /home/phil/www/disable_script.php
But I'm immediately greeted by this:
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/zlib.so' - /usr/lib/php4/zlib.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Call to undefined function: date_default_timezone_set() in /home/phil/www/disable_script.php on line 3
When I just say:
php -v
I get:
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/zlib.so' - /usr/lib/php4/zlib.so: cannot open shared object file: No such file or directory in Unknown on line 0
What should my next step be? Do I need to reinstall php?
Sounds like there's a setting in your php.ini that is trying to load an extension that it can't find. Check to make sure the extension exists or edit your php.ini so it doesn't try to load the extension.
Also, date_default_timezone_set() is only available in PHP 5.1.0 or later. Your install looks to be PHP4.
PHP4 is old, ugly and not supported anymore. You should upgrade to PHP5 as soon as possible.
before that extension list (the .so's resp. dll's on Windows) the php.ini says:
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
I had luck with giving an explict path, i.e.
extension=d:\dev\fronker\php\ext\php_openssl.dll

Categories