From: | ghoffman(at)ucsd(dot)edu (Gary Hoffman) |
---|---|
To: | ehb(at)one(dot)net |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] PHP and Postgresql 6.5.1 |
Date: | 1999-07-27 18:08:35 |
Message-ID: | fc.00249f0e003839d63b9aca0080564995.3839df@irpsbbs.ucsd.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Eric,
I've got my PHP running fine with PostGreSQL inthe past couple of weeks.
Here is a page that pulls out current members from my club roster and
displays some directory information in a table. I'm kinda proud of the
recursive (ir is it re-iterative?) sections. (Page edited to delete
impertinent identifying data.)
Don't forget to grant the Apache server (user www) select access to your
database or explicitly log in with a valid PostGreSQL user name.
Cheers,
Gary
----------------
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
<HTML><HEAD><TITLE>CGSSD Member Directory</TITLE></HEAD><BODY
TEXT="#000000" BGCOLOR="#E7E7EF" LINK="#0000EE" VLINK="#551A8B"
ALINK="#FF0000">
<H1 ALIGN=CENTER>Member Directory</H1>
<font size=4>CGSSD membership information is current as of June 1999. This
directory is for the non-commercial use of its members only. Any other use
is <u>prohibited</u>.<p>
<p>Please wait for directory to load.<br>
<?php
flush();
if (!$conn = pg_Connect("","","","","cgssd_members")){
echo "Error! Can't connect to database.";
exit;
}
$query = "select * from memdir4 where status = 'A' order by lower(lname),
lower(fname)";
if (!$result = pg_exec($conn, $query)){
echo "Error while processing query.<br>";
pg_close($conn);
exit;
}
$rows = pg_NumRows($result);
echo "$rows members in directory!\n";
# the non-breaking space is the best way I could find to control column
widths
echo "<p><p><table border=1 cellpadding=3><tr><th
width=200> Name &n
bsp; </th>\n";
echo "<th width=80>Phone</th><th
width=30> Program </th><th
width=100>E-Mail Address</th><th>Web Page</th></tr><p>\n";
for ($j=0; $j < $rows; $j++) {
$member = pg_result($result, $j, 0) . ", " . pg_result($result, $j, 1);
echo "<tr><td>" . $member . "</td>\n";
if (!pg_result($result, $j, 2) or !pg_result($result, $j, 3) or
!pg_result($result, $j, 4)) {
echo "<td> </td>";
}
else {
echo "<td>" . pg_result($result, $j, 2) . "-" . pg_result($result, $j, 3)
."-" . pg_result($result, $j, 4) ."</td>\n";
}
if (!pg_result($result, $j, 5)) {
echo "<td> </td>";
}
else {
echo "<td>" . pg_result($result, $j, 5) . "</td>\n";
}
if (!pg_result($result, $j, 6)) {
echo "<td> </td>";
}
else {
echo "<td><a href=mailto:\"" . pg_result($result, $j, 6) . "\">" .
pg_result($result, $j, 6) ."</a></td>\n";
}
if (!pg_result($result, $j, 7)) {
echo "<td> </td>";
}
else {
echo "<td><a href=http://\"" . pg_result($result, $j, 7) . "\">" .
pg_result($result, $j, 7) ."</a></td>\n";
}
}
echo "</tr></table>";
?>
</body></HTML>
---------------------
ehb(at)one(dot)net writes:
>I downloaded and compiled the most recent version of PHP and Apache.
>The PHP module functions properly when parsing commands such as
>echo and variable declarations. However when I submit a query through
>pg_exec and try to display the results using pg_Fetch_Array, I get
>"Document
>Contains No Data." I followed the instructions provided by PHP to test
>for
>segmentation fault and have come to the conclusion that when
>PHP attempts
>to post the query to the database, it blows up in segmentation fault.
>
>Does PHP work with Postgresql 6.5.1 at this time?
>
>Please reply to this list as well as my personal email account as soon
>as possible.
>
>Thank you!
>
>Eric Buschelmann
>Systems Analyst
>ehb(at)one(dot)net
**************************************************************************
* Gary B. Hoffman, Computing Services Manager e-mail: ghoffman(at)ucsd(dot)edu *
* Graduate School of International Relations and Pacific Studies (IR/PS) *
* University of California, San Diego (UCSD) voice: (858) 534-1989 *
* 9500 Gilman Dr., La Jolla, CA 92093-0519 USA fax: (858) 534-3939 *
**************************************************************************
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Lynch | 1999-07-28 00:59:27 | Veiw join & rest of table? |
Previous Message | Mike Mascari | 1999-07-27 16:41:51 | Re: [GENERAL] Problem Compiling C-functions |