2 more questions(Was: Re: psql with PHP question)

From: Jason <gee308(at)mediaone(dot)net>
To: Adam Lang <aalang(at)rutgersinsurance(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: 2 more questions(Was: Re: psql with PHP question)
Date: 2001-05-03 14:06:10
Message-ID: 3AF165D1.D9F6420E@mediaone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-php

Thanks for the help, sorry for cross posting.
I have 2 more questions. I am a newb with psql and PHP. I am creating a
slashdot like site. First, what is the best way to store an article? Inside
psql or just reference the path inside psql or is there another method? I am
currently using the path inside psql then use readfile() from PHP to display
the file. Second, Can you guys with experience tell me where I am writing
code improperly or give some tips? This short code segment just displays the
article and comments posted with it. Thanks:

<?
include("./phpinc/psql.php");
include("./phpinc/func.php");
include("./phpinc/var.php");
include("/usr/local/apache/phpinc/variables");
include("/usr/local/apache/phpinc/header");

if (!$conn)
echo "Site is temporarily down";

else {
if(isset($sid)){
$q1 = pg_Exec($conn,"select author,title,path,description from article
where sid=$sid");
$arr = pg_fetch_array($q1, 0);
echo "By ". $arr["author"] .": ". $arr["title"] ."<br>";
echo $arr["description"] ."<br><br><br>";
echo $arr["path"]."<br>"; //this line is just for seign if the path is set
correctly
readfile($arr["path"]);
// echo $arr["path"];

//next 3 lines are jut for replying to the article
echo "<table width=100% bgcolor=$table1><tr><td align=right><form
action=submit.php?sid=$sid method=post>";
echo "<input type=submit value=Post></tr></td></table>";
echo "<BR><BR><BR><BR>";

//start the comments section here
$q3 = pg_Exec($conn, "select cid from comment where article='$sid'");
$maxid = pg_numrows($q3);
$q2 = pg_Exec($conn,"select uname,time,date,post,ctitle,cid from comment
where
article=$sid");
if(!empty($maxid)){
for($i=0;$i<$maxid;$i++){
$arr2 = pg_fetch_array($q2, $i);
echo "By ". $arr2["uname"] .": ". $arr2["ctitle"] ."<br>";
echo $arr2["post"] ."<br>";
echo "<a href=./submit.php?sid=$sid&cid=". $arr2["cid"] .">Reply to
this</a><br><br>";
}
}
}
}
include("/usr/local/apache/phpinc/footer");

?>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-03 14:14:51 Re: troubles with postgresql 7.0.2
Previous Message Tom Lane 2001-05-03 14:05:18 Re: troubles with postgresql 7.0.2

Browse pgsql-novice by date

  From Date Subject
Next Message Andy Howarth 2001-05-03 14:27:16 Re: Problems compiling 7.1 with TCL support on Solaris 7
Previous Message Jason 2001-05-03 13:43:44 Re: psql with PHP question

Browse pgsql-php by date

  From Date Subject
Next Message Andy Howarth 2001-05-03 14:27:16 Re: Problems compiling 7.1 with TCL support on Solaris 7
Previous Message Jason 2001-05-03 13:43:44 Re: psql with PHP question