Archive

Archive for the ‘PHP’ Category

Path to php.ini is incorrect in phpinfo() on Windows

January 28th, 2009 No comments

I just did a manual install of php on a windows xp box using IIS and no mysql server.  The mysql server is on another box.  However, in order to get my scripts to work with the mysql server, I need to load the php_mysql extension within the php.ini file.

I was able to get PHP running correctly (the file-level permissions are really picky if your running into trouble) but I  noticed from phpinfo() that the mysql extension was not showing up and that path to php.ini was not correct.

By default PHP recommends placing the php.ini file in the same directory as the other php files, usually something like c:\php.  However, even when the windows system path variable is setup and the machine rebooted, php is not looking for its own .ini file.

The resolution is to place the php.ini file in the C:\windows directory and restart the web service.  Apparently php is compiled with the windows directory as default and doesn’t want to change the path.

Printing directly from PHP

January 12th, 2009 No comments

The inherent nature of PHP makes it difficult to print directly from a PHP page.  PHP is a web based scripting language that is based on a server/client architecture.  For security reasons, PHP tries to maintain a separation from the server and any printers attached to the server.

Luckily for us, this separation is not perfect, and there are ways around it.

Two possible methods for printing directly from PHP

  • Use the embedded printer functions in PHP (windows only)
  • Use the embedded program execution functions in PHP to execute scripts (linux or windows)

The method I came up was using the embedded printer functions in PHP.  My main web server was linux based, but I setup a separate windows server running IIS and PHP to facilitate direct printing.  The linux server does a server request to the windows server, and passes a query string of information.  The windows server then takes this query string information and uses it to print something directly to a printer.  This method is very stable and was made the primary method for printing from an ERP system for a large warehouse.

Requirements:

  • Windows XP or 2000 web server
  • IIS installed
  • PHP installed
  • Php_printer.dll from PECL extensions (http://pecl.php.net/)

Instructions:

  • Copy the php_printer.dll into the php extensions directory.
  • Edit the php.ini, in the windows extensions section, add the entry “extension=php_printer.dll” after the php_sqlite item
  • Install printers onto the server
  • Install a code39 font if barcodes are desired
  • From this point forward, use the printer functions build into PHP to send print jobs directly to a printer attached to the server. (http://us3.php.net/manual/en/book.printer.php)

Code samples coming soon.

Categories: PHP Tags: , ,