Page 1 of 1

Fatal error: Call to undefined function printer_open()

PostPosted: 09. April 2010 09:13
by vijayk
hi all,

I am writing the below PHP code to print the job automatically, when i run PHP program.

<?php
$filename = "test.php";
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
$handle = "Phaser 5550DN PS";
$handle = printer_open();
printer_set_option($handle, PRINTER_MODE, "raw");
printer_write($handle,$contents);
printer_close($handle);
?>

But, the above code giving error "Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\xampp\printtest.php on line 8" .

since, i am new to PHP, pls help me get work.

thanks
rgs
vijay

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 09. April 2010 23:23
by MC10
printer_open() is not a valid function; you can't use PHP to actually print something from a printer.

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 09. April 2010 23:30
by Altrea
MC10 wrote:printer_open() is not a valid function; you can't use PHP to actually print something from a printer.

printer_open()

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 09. April 2010 23:32
by MC10
Okay, my bad, it just seems unlikely for a PHP script to allow printing; an evil site could make your printer start printing random things at random times.

From http://www.php.net/manual/en/printer.installation.php:
php.net wrote:This PECL extension is not bundled with PHP.

Windows users must enable php_printer.dll inside of php.ini in order to use these functions. A DLL for this PECL extension is currently unavailable. See also the building on Windows section.


XAMPP does not include the .dll, so the functions are not defined.

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 10. April 2010 00:48
by Narrowboyy
The last XAMPP version that included the php_printer.dll was 1.7.1 (the corresponding extension in the C:\xampp\php\php.ini file has to be uncommented to use it).

So if you still want to use this function until there is an official upgrade released then you would have to install XAMPP 1.7.1 version from the SourceForge Repository.

Note and personal comment only.
As far as I am personally concerned 1.7.1 was the last good XAMPP release, as versions after this appear to have many issues that have not been adequately documented or addressed by the current (sloppy) XAMPP for Windows development team, with the current 1.7.3 being the absolute worst release so far - the volume of 1.7.3 issues on this forum would seem to testify this observation.

Perhaps the solution would be for a wider range of knowledgeable XAMPP beta testers to really give these intended new release a thorough work out.

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 12. April 2010 11:03
by vijayk
hi all

I tried few methods like i.adding 'php_printer.dll ' in PHP.ini file ii. add the ddl in script. but doesnt work. if you give anyworkable solutions, it will help lot.
thanks
rgs
vijay

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 12. April 2010 14:03
by Nobbie
vijayk wrote:I tried few methods like i.adding 'php_printer.dll ' in PHP.ini file ii. add the ddl in script. but doesnt work.


This helps only if you have a valid copy of php_printer.dll on your hard disk (in the extensions folder of PHP). Did you find that DLL on your PC?

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 13. April 2010 08:01
by vijayk
Hi Nobbie
Yes. am able to see the dll in 'c:\xampp\php' directory. But, its not working.
thanks

Re: Fatal error: Call to undefined function printer_open()

PostPosted: 13. April 2010 10:33
by Nobbie
vijayk wrote:Yes. am able to see the dll in 'c:\xampp\php' directory.


That's the wrong location, extension should be stored in c:\xampp\php\ext and not in c:\xampp\php - did you put it there? Move it to the ext-folder, and restart Apache. You should also 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.