pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ângelo Marcos Rigo <angelo_rigo@yahoo.com.br>
To: pgsql-php@postgresql.org
Subject: Update script
Date: Thu, 14 Aug 2003 10:46:46 -0300 (ART)
Message-ID: <20030814134646.77797.qmail@web14805.mail.yahoo.com> (raw)

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 :

<?php
	$id = $_POST['id'];
	$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:<P> -
$titulo<BR>- $texto<BR>");
	pg_close($db);
?>

This is a snip from modificar_1.php

<?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;
	?>
	<table border=0 style="border: 1px solid black;">
	<?php
		do {
		$myrow = pg_fetch_row ($result, $row);
		//print_r($myrow);
		print ("<tr><td>ID</td><td>$myrow[0]</td></tr>");
		print ("<tr><td>Título</td><td><input type=text
value=$myrow[1] name=titulo size=150
maxlength=150></td></tr>");
		print ("<tr><td>Texto</td><td><textarea cols=90
rows=20 value=$myrow[2]
name=texto>$myrow[2]</textarea></td></tr>");
		$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



view thread (6+ messages)  latest in thread

Message-ID: <20030814134646.77797.qmail@web14805.mail.yahoo.com>
Permalink:  ../20030814134646.77797.qmail@web14805.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030814134646.77797.qmail@web14805.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: angelo_rigo@yahoo.com.br
  Subject: Re: Update script
  In-Reply-To: <20030814134646.77797.qmail@web14805.mail.yahoo.com>
  References: <20030814134646.77797.qmail@web14805.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox