2 more questions(Was: Re: psql with PHP question) - Mailing list pgsql-php

From Jason
Subject 2 more questions(Was: Re: psql with PHP question)
Date
Msg-id 3AF165D1.D9F6420E@mediaone.net
Whole thread Raw
In response to psql with PHP question  (Jason <gee308@mediaone.net>)
List 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");

?>


pgsql-php by date:

Previous
From: "Adam Lang"
Date:
Subject: Re: psql with PHP question
Next
From: Jason
Date:
Subject: Re: psql with PHP question