Linux

Warning: Failed opening 'leftblock.php3' for inclusion (include_path='.:/usr/share/pear') in /home/matrix/html/examples/php-post.php on line 15

Linux PowerHouse Station
Presented by:  Kimmie Dicaire 


 
 
 
PHP / Postgresql Examples and Functioning Code


This tutorial will assume that you have both PHP and Postgresql installed and functioning. Both PHP3 and Postgresql have very detailed instructions in the source code directory. Read the REAME and INSTALL files for each, and follow them EXACTLY as written for a smooth install. IF you try to jump ahead or skip steps then you will not have a proper install and will have to start over from scratch.

We will start with a few basics and build a Postgresql database for these examples. Then we will show you how to implement PHP3 code into your web files to access the newly created database. This site is for beginners of PHP3 usage, therefore you will not see very much as far as complicated code. The advanced PHP3 users section is still in process of being designed, please check back frequently for its arrival.

For best results please follow the entire tutorial step by step so you get the best possible understanding of the process from database creation to PHP3 usage. If you prefer to jump ahead to the PHP code click here

Lets begin the creation of our new database. For your convience all issued commands will be in bold. Make sure postmaster is running with the -i switch. You may do ps ax |grep post on the commandline as root to see if it is running. If its running proceed to the next step. If it is not running then login as the postgres user and start it up, NEVER start postmaster as any other user than postgres. You can start it up with a command like this /usr/local/pgsql/bin/postmaster -i & If you do not know the full path to the executable you can run this command as root to find it which postmaster

Now as the postgres user type CREATEDB phonelist then hit enter. This will create the database called phonelist.
Now i will give you the schema of the database. Schema means the tables, indexes, and so forth that gives your database its guts. First as your postgresql user type psql and that will put you into the database with a commandline interface. (NOTE: Some of you may know postgres pretty well and be used to using pgaccess, feel free to create your database that way if you are more comfortable with it.) Now type \connect phonelist
Once you are connected to the phonelist database you will issue this command to create a couple of sequences. Sequences are unique numbers that identify each record and are inserted sequentually with each new entry:

CREATE SEQUENCE config_seq START 1 INCREMENT 1;


Now lets give the database a table with some fields.:

CREATE TABLE "address" (
"last" text NOT NULL,
"first" text NOT NULL,
"phone" text,
"address" text,
"birthday" text,
"email" text,
"fax" text,
"beeper" text,
"cellphone" text,
"notes" text,
"city" text,
"state" text,
"zip" text,
"spouse" text,
"workphone" text,
"name" text NOT NULL,
"date" date DEFAULT 'now ()' NOT NULL,
"uid" int4 DEFAULT nextval ( 'config_seq' ) NOT NULL,
"url" text,
"area_code" INT4,
"country" text,
"nickname" text,
"title" text,
"company" text,
"department" text,
"anniversay" text );

NOTE: To find out more on how to use PostgreSQL check out the Postgresql manuals for best comprehension. Start with the select statements in the manual to play with your newly created database.

Ok now your database is functional and ready to be used with PHP3 to access it via your web server.

When we leave this page and begin our journey into PHP3 all the code will be color coded for your convience and to catch your eye. I will be doing this by using the extention .phps for these examples instead of the standard extention .php3. In order for the sample code to actually work you will need to use the standard extention .php3 when you name your pages. Without further ado lets move onto the PHP3 intergration part of this tutorial, just click here to be on your way.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

© 1998 K&R Information Technologies
Linux PowerHouse Station
 
 
Linux

Warning: Failed opening 'right.php3' for inclusion (include_path='.:/usr/share/pear') in /home/matrix/html/examples/php-post.php on line 151