Received: from relay2.shore.net (relay2.shore.net [207.244.125.21]) by hub.org (8.10.1/8.11.0) with ESMTP id e9IBg9W41761 for ; Wed, 18 Oct 2000 07:42:09 -0400 (EDT) (envelope-from drp@shore.net) Received: from netmnch-s01-70.port.shore.net (wind) [204.167.102.70] by relay2.shore.net with smtp (Exim) id 13lrbs-0003yB-00; Wed, 18 Oct 2000 07:42:16 -0400 Message-Id: <3.0.6.32.20001018073852.007e8d50@shell1.shore.net> X-Sender: drp@shell1.shore.net X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Wed, 18 Oct 2000 07:38:52 -0500 To: Chris From: Dave Perkins Subject: Re: files, php & pgsql Cc: pgsql-php@hub.org In-Reply-To: <4.3.2.7.2.20001018185338.00a9fcb0@mail.pharm.usyd.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200010/29 X-Sequence-Number: 44 Ahhh . . . Guess this is likely not to be the problem, as it is clear that it's the formatting of the message that breaks the line. Oops. I'll let you know if I discover anything else. Dave At 08:45 PM 10/18/00 +1000, you wrote: >I've been thinking the same that the list is dead (or my mail was stuffed) >but now I see it's not the case :) > >I do have a problem (!!), and its trying to get files (of any type) to work >with pgsql & php. I'm using pgsql 7.0.2, php4. > >Anyone have any hints? > >Chris. > >Here's the form I use to upload the files.. >
action="file-insert.php" method="post"> > >
> > >I upload the files like this.... >$db=pg_connect("","","","","images"); >$fp=fopen("$userfile","r"); >pg_exec ($db,"begin"); >$loid = pg_locreate($db); >$lofp = pg_loopen($db, $loid, "w"); >while ($nbytes = fread ($fp, BUFSIZE)) >{ >$tmp = pg_lowrite($lofp, $nbytes); >if ($tmp < $nbytes) echo "Error writing the file"; >} >$sql = "insert into images (picnum, image) values >(nextval('images_picnum_seq'), '$loid')"; >pg_exec($db,$sql); >pg_loclose($lofp); >pg_exec($db, "commit"); >fclose($fp); >echo "done"; >pg_close($db); >?> > >I list the files like this.. >$db = pg_connect("","","","","images"); >$sql = "select * from images"; >$result = pg_exec($db, $sql); >if (!$result) {printf ("error"); } >$totalrows = pg_numrows($result); >$row=0; >do >{ >$myrow = pg_fetch_object($result,$row); >$image_oid = $myrow->picnum; >echo "this is my image border=0>
"; >$row++; >}while ($row < $totalrows); >echo $pic; >?> > >I (try to) display the files like this.... >$db=pg_connect("","","","","images"); >$sql="select * from images where picnum=$picnum"; >$result=pg_exec($db,$sql); >if (!$result) { printf ("error"); } >Header("Content-type: image/gif"); >$myrow = pg_fetch_object($result,0); >$image = $myrow->image; >pg_loreadall($image); >pg_close($db); >?> > >and finally my database.. >images=# \d images > Table "images" > Attribute | Type | Modifier >-----------+---------+------------------------------- > picnum | integer | not null default...... > image | oid | > >