SQL Update in Postgres with PHP

admin

Administrator
Staff member
Hi, folks -

I'm very new to the Postgres/MySQL/PHP land, but I do have a bit of experience with relational databases.

Right now, I'm tearing my hair out over the following: I'm trying to UPDATE a particular record in a database table and keep being greeted with this error:

-----
Warning: PostgreSQL query failed: ERROR: parser: parse error at or near "desc" in /usr/local/apache/htdocs/dev/update.php on line 7
ERROR
-----

I've pored over eveything I can find to try to fix this, but have been unable to so far. I very much appreciate any assistance you can provide me.

Here is the file update.php, which is called from a form named index3.php:

UPDATE.PHP

<body>
<?php

$db = pg_connect("dbname=mfm user=pgsql");
$query = "UPDATE abouta SET desc='$description' where id='$id'";
$result = pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
printf ("These values were updated in the database - %s %s",$id, $desc);
pg_close($db);
?>
</body>


INDEX3.PHP

<body>
<?php

$db = pg_connect("dbname=mfm user=pgsql");
$query = "SELECT * FROM abouta";
$result = pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
$numrows = pg_numrows($result);
$row=0;
printf ("<table border=1>\n");
printf ("<tr><td>ID</td><td>Description</td></tr>\n");
do
{
$myrow = pg_fetch_row ($result,$row);
printf ("<tr><td>%s</td><td>%s</td></tr>\n", $myrow[0],
$myrow[1], $myrow[2]);
$row++;
}
while ($row < $numrows);
printf ("</table><br>\n");
pg_close($db);
?>
<form action="update.php" method="post">
ID to Update : <input type="text" name="id" size="4" length="4" value=http://www.phpbuilder.com/board/archive/index.php/"ID"><br>
Description : <input type="text" name="description" size="40" length="40" value$
<input type="submit" name="submit" value="Update It">
<input type="reset" name="reset" value="Clear It">
</form>
</body>
 
Back
Top