July 2005
Intermediate to advanced
1032 pages
27h 10m
English
The first PHP/PostgreSQL client establishes a connection to a PostgreSQL server and displays the name of the database to which you connect. Listing 15.4 shows the client1a.php script.
1 <?php 2 //Filename: client1a.php 3 4 $connect_string = "dbname=movies user=bruce"; 5 6 $db_handle = pg_connect( $connect_string ); 7 8 echo "<HTML>\n"; 9 echo "<HEAD>\n"; 10 echo "<TITLE>client1</TITLE>\n"; 11 echo "<BODY>\n"; 12 echo "<CENTER>"; 13 echo "Connected to " . pg_dbname( $db_handle ); 14 echo "</CENTER>\n"; 15 echo "</BODY>\n"; 16 echo "</HTML>"; 17 ?> |
This script connects to a database whose name is hard-coded in the script (at line 4). At line 6, you attempt to make a connection by calling ...
Read now
Unlock full access