June 2002
Intermediate to advanced
800 pages
16h 3m
English
Error handling is one of the most important things—not only when working with databases. PHP and PostgreSQL have error-handling mechanisms that are easy to use and reliable.
Let's create a table for storing telephone numbers:
phpbook=# CREATE TABLE phone (id serial, name text, phone text NOT NULL);
NOTICE: CREATE TABLE will create implicit sequence 'phone_id_seq' for SERIAL
column 'phone.id'
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'phone_id_key' for
table 'phone'
CREATE
The last column has been defined as NOT NULL, which means that a value has to be added to the column. In the next step you can try to write a script that tries to insert some data into the table:
<?php $connstr = "dbname=phpbook ...
Read now
Unlock full access