php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18408 printer_list crashes PHP
Submitted: 2002-07-18 05:57 UTC Modified: 2018-08-13 07:28 UTC
Votes:13
Avg. Score:4.6 ± 0.7
Reproduced:8 of 10 (80.0%)
Same Version:2 (25.0%)
Same OS:6 (75.0%)
From: info at Frenck dot nl Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 4.2.1 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
16 + 41 = ?
Subscribe to this entry?
Further comment on this bug is unnecessary.
 
 [2002-07-18 05:57 UTC] info at Frenck dot nl
Hi,

I'm having troubles using the printer_list function.
When I try to get a list of all the printers installed
on the machine where the script is running, php crashes.

When I use this code, PHP crashes:

  printer_list(PRINTER_ENUM_LOCAL);

When I use this codes, PHP does not crash, but it returns
a empty array.

  printer_list(PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED);

  printer_list(PRINTER_ENUM_SHARED);

When I accessing the script with my browser (trough apache) apache crashes, when I running it as an command line script, PHP.exe crashes.

Altough, printing to the default printer with the example listed at 'http://www.php.net/manual/en/function.printer-draw-text.php' works fine.

I'm running PHP 4.2.1 (in apache it's the NON-CGI version running) on windows XP Professional Dutch edition.

Microsoft Visual C++ tells me there is an access violation in php.exe (php4ts.dll)

Is there a workaround for this problem?
If you need more information, than feel free to contact me.

With kind regards,

Franck Nijhof

PS: Sorry for my bad english.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-19 23:17 UTC] iliaa@php.net
Appears to be an abandoned PECL extension.
 [2003-06-14 11:43 UTC] saidyjade at hotmail dot com
windows nt40 sp6
windows 2000 pro sp3 + pre-sp4 updates @ 20030609

PHP 4.3.2 / Apache 1.3.27 / php4apache.dll 
extension: php_printer.dll

The extension does appear to be in the category "who cares".

only crashes only the array keys "DESCRIPTION" and "COMMENT"

$list_printers = printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED);

// get the name of the first returned printer
$this_printer = $list_printers[0]["NAME"];

// open a connection to your printer
$my_printer = printer_open($this_printer);

.. blah blah


The output of var_dump (as an example)

var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) );

array(1) {
  [0]=> array(3) {
  ["NAME"]=> string(14) "Canon BJC-4550"
  ["DESCRIPTION"]=> string(30) "Canon BJC-4550,Canon BJC-4550,"
  ["COMMENT"]=> string(0) "This is my funky printer!" } }


As you can see var_dump (under variable functions in the manual) shows and/or retrieves the corrent information but if you try to place into a variable or read the variable it crashes with an "I am a windows product and cannot read the memory space correctly cause I sux" message.

so as long as you do not get the comment or description it will list your printers.

if you wish to specify a network printer you need lots more slashes.. example: \\\\my-network-computer\\my-printer-share

cher cher
 [2013-05-14 14:10 UTC] fziu02 at gmail dot com
You can use AJAX, and everything works fine...

PHP // lsprt.php
<?php
    $getprt=printer_list( PRINTER_ENUM_LOCAL );
    echo json_encode($getprt);
?>

HTML
<script>
$.post('lsprt.php', function(data) {
	value = JSON.parse(data);
	for (val in value) {
		$('#asd').append('<option value="'+ value[val]['NAME'] +'">'+ 
value[val]['NAME'] +'</option>');
	}
});
</script>

<select id="asd"></select>
 [2014-04-17 07:04 UTC] lefteris-l at idata dot gr
Hello,

To whoever might still be using this i've come across the same issue.

For some reason using 

$printer_list = printer_list(PRINTER_ENUM_LOCAL); TWICE in the same page

seemed to be working fine for me and showing up all printers EXCEPT when i would add more lines to the code it would crash.
And by lines i mean a couple of more characters in an HTML text could be enough. (Not even php code).

Anyway I then moved from Mysql to Mysqli and boom.
Stopped working. I played around some more time and now i use

$printer_list = printer_list(PRINTER_ENUM_LOCAL |PRINTER_ENUM_SHARED);

once again TWICE. Problem is now it only shows me 1-2 printers.
I can access DESCRIPTION and COMMENT just fine the same way i'm accessing the NAME
    foreach ($printer_list as $printerAr)
    {
    	$name = $printerAr["NAME"];
    ... }
Hope it might save some time someone else in the future.
Lefteris
 [2018-08-13 07:27 UTC] meansakti at gmail dot com
Epson error code 0xEa is a most common error with Epson printer If you are an Epson Printer and facing this issue contact service provider team as soon as possible and solved this issue.
For more information about this error visit this link http://printertechsupportnumbers.com/blog/how-to-fix-epson-error-code-0xea/
 [2018-08-13 07:28 UTC] requinix@php.net
-Block user comment: No +Block user comment: Yes
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 12:01:29 2019 UTC