Jump to content

[SOLVED] Server side printing using PHP


nodehopper

Recommended Posts

I am completely new to PHP. I have a small MySQL database here at work with all the information for our Micro Biological Samples. A previous employee wrote up some internal web pages that interact with the database. The employee has left and I now need to move everything over to a WAMP Server. He had originally set it up on LAMP. Many of the pages have simply required editing paths and the database connection parameters. Not too tough, but now I am stumped.

 

I plan on learning PHP, but before I have the luxury of time to do that I need to get a couple interfaces working ASAP. Both rely on PHP to print barcode labels with information taken out of the database and it is formatted in a temporary .prn file. As far as I can tell this all functions except for the printing. The previous employee used the smbclient in linux which is of course not available on Windows Server.

 

Here is the code that I think does the printing.

 

$fhandle=fopen("strainlabeltemp.prn","w");

fwrite($fhandle,$labelText);

fclose($fhandle);

print("<!-- $labelText -->\n");

$results=`/usr/bin/smbclient -N //labelprint/ZEBRA -c 'print strainlabeltemp.prn' 2>&1`;

print("<!-- Results: $results\n -->\n");

 

Can anyone show me how to edit this so instead of calling smbclient on a LAMP server it will send this to the shared network Zebra printer that is set up on the WAMP server as LPT1. Please remember I am not familiar with PHP so I need a reply back that is geared toward a completed idiot like me.

 

Thanks in advance for any help with this!

 

Stephen

Link to comment
Share on other sites

not sure if this helps

but

$results=`/usr/bin/smbclient -N //labelprint/ZEBRA -c 'print strainlabeltemp.prn' 2>&1`;

is basically a command line.. this is used later probably exec($results); or system($results);

 

Now to fix this, you need to find out how to print from the command line

this may work

change

$results=`/usr/bin/smbclient -N //labelprint/ZEBRA -c 'print strainlabeltemp.prn' 2>&1`;

to

$results='print /d:LTP1 strainlabeltemp.prn';

Link to comment
Share on other sites

Thanks so much MadTechie. I ended up having to put a little more work into this, but you definitely got me pointed in the right direction. Also because of your answer I was able to do a better search and found one other post that added a few more pieces to the puzzle. I was also able to connect with the original author via IM to get the last little details iron out.

 

see http://www.phpfreaks.com/forums/index.php/topic,207946.0.html  thanks jonsjava ---indirectly helping me.

 

So here is what I got to work. This is on a WAMP server on Win Server 2003 and it now prints to a Zebra barcode printer that is shared on the network. I just commented out the old Linux LAMP based call to the printer and changed it so it prints from the WAMP server.

 

$fhandle=fopen("strainlabeltemp.prn","w");

            fwrite($fhandle,$labelText);

            fclose($fhandle);

            print("<!-- $labelText -->\n");

            $printcmd='PRINT /d:\\\\labelprint\ZEBRA strainlabeltemp.prn';

            $results=shell_exec($printcmd);

            /*$results=`/usr/bin/smbclient -N //labelprint/ZEBRA -c 'print strainlabeltemp.prn' 2>&1`;*/

            print("<!-- Results: $results\n -->\n");

 

Thanks again ...one and all for the help. I pan on hanging out here more and hopefully learning me some PHP.

 

Sorry....I can't seem to find the option to mark this solved.

 

Stephen

           

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.