X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 683F0D1F6FC for ; Thu, 14 Aug 2003 14:03:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23358-06 for ; Thu, 14 Aug 2003 11:02:11 -0300 (ADT) Received: from mail1.dr.myx.net (mail1.dr.myx.net [217.10.193.161]) by svr1.postgresql.org (Postfix) with ESMTP id AFE52D1F482 for ; Thu, 14 Aug 2003 10:59:17 -0300 (ADT) Received: from workstation24 (unknown [81.12.137.146]) by mail1.dr.myx.net (mydomain.myx.net) with ESMTP id 69585300A0A for ; Thu, 14 Aug 2003 16:59:19 +0300 (EEST) Message-ID: <001901c3626c$076efc90$0600a8c0@fix.ro> From: "Viorel Dragomir" To: References: <20030814134646.77797.qmail@web14805.mail.yahoo.com> Subject: Re: Update script Date: Thu, 14 Aug 2003 16:57:41 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/56 X-Sequence-Number: 2233 ----- Original Message ----- From: "Ângelo Marcos Rigo" To: Sent: Thursday, August 14, 2003 4:46 PM Subject: [PHP] Update script > Hi > > I have a script to update some records in a postgresql > database. when i do modify what i have to modify it > give me the warning: > > Warning: pg_query() query failed: ERROR: pg_atoi: > zero-length string in > /var/www/html/adm/modificar_2.php on line 24 > ERROR > > this is line 24: > $result = pg_query($db, $query); > > this is modificar_2.php : > > $id = $_POST['id']; Since this is the only thing that match an integer value, try to use $id = $_POST['id'] + 0; in case there is no id sent. You'll don't get any results [i hope there is no id==0] but u'll don't have an error on your query. Because id is integer try not to use *where id='$id'*. Use *where id=$id* instead. > $titulo = $_POST['titulo']; > $texto = $_POST['texto']; > > include 'db.php'; > $query = "UPDATE table SET titulo='$titulo', > texto='$texto' WHERE id='$id'"; > $result = pg_query($db, $query); > if (!$result) {printf ("ERROR"); exit;} > print ("Estes valores foram atualizados:

- > $titulo
- $texto
"); > pg_close($db); > ?> > > This is a snip from modificar_1.php > > $id = $_POST['id']; > $titulo = $_POST['titulo']; > $texto = $_POST['texto']; > > include 'db.php'; > $query = "SELECT id, titulo, texto FROM table WHERE > id='$id'"; > $result = pg_exec($db, $query); > if (!$result) {printf ("ERROR"); exit;} > $numrows = pg_numrows($result); > $row=0; > ?> > > do { > $myrow = pg_fetch_row ($result, $row); > //print_r($myrow); > print (""); > print (""); > print (""); > $row++; > } > while ($row < $numrows); > ?> > > Thanks in advance > > > ===== > Ângelo Marcos Rigo > AMR Informática > (51) 3348 0870 > Rua Pe. Alois Kades 400/210 > Porto Alegre /RS/Brasil > http://amr.freezope.org > angelo_rigo@yahoo.com.br > > > > _______________________________________________________________________ > Conheça o novo Cadê? - Mais rápido, mais fácil e mais preciso. > Toda a web, 42 milhões de páginas brasileiras e nova busca por imagens! > http://www.cade.com.br > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org
ID$myrow[0]
Título value=$myrow[1] name=titulo size=150 > maxlength=150>
Texto