Using PDFToText to convert PDFs to text

Using PDFToText to convert PDFs to text

PDF to Text ConversionThis is geared towards windows users. Pdftotext is a program for converting PDF files to text. for windows you can get it as part of the Xpdf open source viewer

From the README:

"What is Xpdf?

Using the HTML::Strip Perl extension

Using the HTML::Strip Perl extension


Example demonstrating how to use the HTML::Strip Perl extension for stripping HTML markup from text.

The results may not perfectly remove all HTML depending on the complexity of your markup.
strips HTML-like markup from text in a very quick and brutal manner. You can also use the extension
to strip XML or SGML from text.


Parsing RSS with Perl

This is based on a script provided in the 'Add RSS feeds to your Web site with Perl XML::RSS' from

In the original script, it was assumed that the rss news feed would be located on your server. To get
around this limitation, use LWP to get the contents of a remote file, save it to a file on your server
then parse the file.

Using fgetscsv function

Using fgetscsv function

Reading the data saved in CSV file format

fgetcsv -- Gets line from file pointer and parse for CSV fields

Fgetcsv() example - Read and print entire contents of a CSV file
The field delimiter is assumed to be a comma, unless you specify another delimiter with the optional third parameter.

PHP Code

PHP Sessions

A session allows you to preserve data across page requests (going from one page to another on a website) by saving the data to variables that you register as being part of a session. Sessions are tracked through cookies or through the URL. I prefer to track sessions through the URL because cookies may not be enabled on the client computer.

If PHP is compiled with --enable-trans-sid then URLs will contain the session id automatically via the constant PHPSESSID.

Uploading Files with PHP

You can use a browser to upload files with PHP. The files can be either text and binary files. PHP has several file manipulation functions, that allow you to control what you do with a file once it has been uploaded, how large the file to be uploaded should be, where it should go after being uploaded etc.

To upload files, create a file upload form:


Fetching and saving the contents of a remote file

Fetching and saving the contents of a remote file

Submit a query to a search engine and save the results to a local file

1. Create a form that submits a query to a search engine.

2. Script should automatically save the query results to a file. Each query should be saved to separate files.

Working with regular expressions: HREF URL Extractor

HREF URL Extractor

Working with regular expressions

To extract the value (URL) of an HREF attribute from a string, use the preg_match or preg_match_all function. This example use preg_match_all to find all the matches.

preg_match_all - Perform a global regular expression match

preg_match_all (pattern (string), target (string), matches (array), optional flags)

Searches target for all matches to the regular expression given in pattern and puts them in matches in the order specified by the flags.

A Closer Look: Five MySQL functions that handle query results

A Closer Look: Five MySQL functions that handle query results

Assigning variable names to a MySQL result set

After executing a query to select data from a MySQL table there are several functions you can use to perform operations on the retrieved data.

mysql_result() - fetches the contents of the specified cell

mysql_data_seek() - moves to the specified row of a result set

mysql_fetch_array() - fetches the next row in the result set as an array

mysql_fetch_object() - fetches the next row in the result set as an object

PHP Shoutbox

PHP shoutbox

Creating a shoutbox using PHP

I have seen a shoutbox described as a chat application to a guestbook. I do not consider a shoutbox a chat application, I think it's more of a simple comment system. Visitors to your website can quickly leave feedback without having to register for chat or a forum and they do not have to answer all the questions that would normally be in a guestbook. Creating a shoutbox with PHP and MySQL is not very difficult.

First create a table to hold the shoutbox data:


Subscribe to RSS