yklxmas Posted June 4, 2007 Share Posted June 4, 2007 Hi all,I need to come up with a script that allows me to read contents from text files and print them out of a network printer. I've tried printer_open function just to try connection to the printer. No luck at all. I made sure the name is correct. The webserver and printer server are 2 different machines. I've also tried add \\printerserver\printername or \\\printerserver\printername. also the ip address of the printer. Still no luck.Has anyone got any ideas? Thanks for the help in advance. Link to comment Share on other sites More sharing options...
vijay Posted June 4, 2007 Share Posted June 4, 2007 Hi.. Have you got any errors..? or have you tried to debug the code..? what are you getting in resulting var..? May I have your peace of code so I can get the things..Regards,Vijay Link to comment Share on other sites More sharing options...
Lulzim Posted June 4, 2007 Share Posted June 4, 2007 \\printerserver\printername or \\\printerserver\printernameYou haven't escaped the backslashes properly.If the location of the printer is \\printerserver\printername , you have to writeprinter_open("\\\\printserver\\printername"); Link to comment Share on other sites More sharing options...
yklxmas Posted June 4, 2007 Author Share Posted June 4, 2007 Hello,I've just tried 2 versions.1,<?php$handle = printer_open("\\\\ILF-SRV\\Ilf-Inf43rpcs"); var_dump($handle);?> The output is NULL.ILF-SRV = name of printer server.Inf43rpcs = name of the printer.The printer is connected using ethernet.2, <?php$handle = printer_open("\\\\DOMAIN1\\Ilf-Inf43rpcs");var_dump($handle);?> DOMAIN1 = Name of the domain.OutputWarning: printer_open() [function.printer-open]: couldn't connect to the printer [\\DOMAIN1\Ilf-Inf43rpcs] in c:\Inetpub\wwwroot\printer1.php on line 3bool(false) Link to comment Share on other sites More sharing options...
justsomeguy Posted June 4, 2007 Share Posted June 4, 2007 The printer functions are only available on Windows, so this may not work if you are using Apache (not sure about that), and it definately won't work if you are using Linux. The null return value indicates that the connection failed, but you should probably be getting an error message. First, just turn on errors and see if you get anything:ini_set("display_errors", 1);error_reporting(E_ALL);If you still see nothing, since it sounds like you have control of the webserver, check php.ini to see where the errors are going (an error log or database maybe) and look up the errors. Also, since you didn't specify in your post, make sure that both the web server and print server are on the same network, the web server needs to be able to communicate with the print server. This does not work if you are trying to use a printer attached to the machine where the web browser is, it must be the server's printer. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.