This site will work and look better in a browser that supports web standards, but it should be accessible for any browser or Internet device.
If you're seeing this message, you may have to scroll to the bottom of the page to see the navigation links.

PHP and PostgreSQL Links and Notes

This is a collection of notes and links that we find useful with PHP.


PHP - Notes

What's My Name? -- you can find out the name of the current document by calling $PHP_SELF. If you're using Apache with PHP under Windows, you'll need to eliminate the path to PHP itself from this:

$PHP_SELF = str_replace($SCRIPT_NAME, "", $PHP_SELF);

What does the error 'Warning: 1 is not a valid PostgreSQL-Link resource' mean?: It can mean one of several things. One, that the postmaster isn't running. Check this by doing this:

ps aux | grep post

One of the items --perhaps the only one-- should be postmaster

Under PHP4, another possibility is that sometimes it doesn't like the name of the variable you're using to do the connecting. Under PHP3, I used: $conn = pg_connect("", "", "", "my_database"). PHP4 doesn't seem to like $conn or it doesn't like the same variable name showing up for different connections. So, change $conn to something else (make sure you're consistant throughout the connection). This bug has been documented on the developer list, so it will probably disappear with Patch Level 3 or 4.

A third possibility --and a cause of many blow-ups in php database connections for me-- is that you try to connect or disconnect multiple times to the database. Loops in particular can cause problems here (e.g. you're looping through a list of things to be added).

I'm getting weird errors with my code and it should be working -- First, try moving part or all of your code about the first html (e.g. the tag). A lot of times this will solve that problem

I'm getting weird errors with my SQL Code (PHP 4) -- Make sure that you don't have it trying to reconnect when there's an existing connection. It'll change the value in the variable you use to track the connection with creating a new connection. Not good.

PHP - General

PHP Manual

PHP Functions Reference

PHP: Manual: PHP Manual


PHP - Setup/Installation

PHP Manual: Installation

PHP Installation Notes

Linux SQL and the Web: Installing PostgreSQL

Install of PHP with Secureweb-SSL and Databases

PHP User Group Resource List is a regularly updated list of how-to's and faqs related to PHP. Good and extensive.


Covers both PHP and PHP with SQL Databases

FAQTS Knowledge Base

PHP Knowledge Base

Anthony Awtrey Consulting - PHP Programming

CNET - Introduction to PHP - 8/3/99

PHP: PHP: Hypertext Preprocessor



Quick and Dirty Search Engine with PHP and MySQL

Hotwired: PHP/MySQL Tutorial Introduction to PHP

RDBMS-backed Sites Case Studies

PHP: Links


Other Documentation

e-gineer - PHP Knowledge Base

Zend articles on PHP. This includes specific articles on Sessions under PHP 4 and Free Energy (how to use includes, etc., to grab items used repeatedly from a central place) and Reference Counting and Aliasing. Zend seems to be the driving force between the addition of Sessions and other critical ecommerce capabilities to PHP. Die proprietary software, die, eh?

Slashdot discusion on PHP & version control - resources

PHP: Links

Another PHP Links Page

Regular Expressions Cheat Sheet


Specific Questions

Passing Form Checkbox values to PHP

Predefined Variables in PHP



Threaded Discussions with PHP/MySQL

Site Navigation with PHP

Image Creation with PHP

Creating a photo-gallery with php There are a number of other good references on how to upload a graphic with a form, including ones at:,



In-House Documents

SQL Cheat Sheet


Official PostgreSQL Documents:

SQL command reference




Guide (intoduction and list of related tools)



Installation and Setup

Installation of PostgreSQL


SQL Tutorials

Linux Focus SQL Tutorial

Installation of PostgreSQL

Part II

Linux, SQL, and the Web

SQL Tutorial


Postgres: Bugs/Troubleshooting

redhat-devel-list 6/99

Re: Have the postgresql rpms been fixed?

Re: How good is Postgres

If you get the error "RestrictionClauseSelectivity: bad value ", Do VACUUM ANALYZE on the table. Usually this means a value in a column that you're querying has gotten messed up. If that doesn't work, try Alter table X rename to Y and then rename it back. The real solution is supposed to be to update to Postgres 6.5 or later.


Official Sites


PostgreSQL Documentation




WDBI Postgres Interface