Thread: Error using update

Error using update

From
Pete Bass
Date:
I'm running Postgres 6.3 with PHP 2 as a web based db application. The
web server is Apache, and the browser is Netscape 4.5

I have a problem with 'update'. A user updated a field (description) for

a single record, but instead of only the specified record being updated,

all the records had the same field updated.

the code used to update the field(s) for a record is:
 $result=pg_Exec($conn,"update $spr set $set where sprid='$sprid'");

It appears that in this case the condition (i.e. where sprid='$sprid')
has been ignored, although previously and subsequently no multiple
updates have been obtained.

Has anyone any ideas?

Also, is it possible to return the number of rows that have been
updated?

Many thanks,

Pete Bass


Re: [GENERAL] Error using update

From
Charles Tassell
Date:
Just a guess, but have you checked your variables to make sure they are
what you expect?  IE, if $set had a semi-colon at the end it could probably
cause this problem.

At 01:04 PM 2/21/00, Pete Bass wrote:
>I'm running Postgres 6.3 with PHP 2 as a web based db application. The
>web server is Apache, and the browser is Netscape 4.5
>
>I have a problem with 'update'. A user updated a field (description) for
>
>a single record, but instead of only the specified record being updated,
>
>all the records had the same field updated.
>
>the code used to update the field(s) for a record is:
>  $result=pg_Exec($conn,"update $spr set $set where sprid='$sprid'");
>
>It appears that in this case the condition (i.e. where sprid='$sprid')
>has been ignored, although previously and subsequently no multiple
>updates have been obtained.
>
>Has anyone any ideas?
>
>Also, is it possible to return the number of rows that have been
>updated?
>
>Many thanks,
>
>Pete Bass
>
>
>************


Re: [GENERAL] Error using update

From
Peter Eisentraut
Date:
On 2000-02-21, Pete Bass mentioned:

> I'm running Postgres 6.3 with PHP 2 as a web based db application.

I'd strongly advise you to update both of these, since hardly anyone
around here will be able to help you much with these.

> a single record, but instead of only the specified record being updated,
> all the records had the same field updated.
>
> the code used to update the field(s) for a record is:
>  $result=pg_Exec($conn,"update $spr set $set where sprid='$sprid'");

Perhaps $set contains a semicolon?

> Also, is it possible to return the number of rows that have been
> updated?

pg_numrows()

--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden