Re: Parsing Data, Table to Form - Mailing list pgsql-php

From Paul Lynch
Subject Re: Parsing Data, Table to Form
Date
Msg-id 40AAE9AC.3070506@exemail.com.au
Whole thread Raw
In response to Parsing Data, Table to Form  ("Yasmine Kedoo" <yazkedoo@hotmail.com>)
List pgsql-php
Hi Yasmine,

Just noticed a mistake in the error checking.  I typed :
if ( ! pg_numrows($rowstoupdate) == 1 )          // expecting a single
row only
however $rowstoupdate should be $rowtoupdate  - take out the 's' .

That will hopefully catch the lack of rows.  Now the real problem lies
in the pg_exec statement.  It is not getting the data from the table.
And its problem is possibly in the $database connection value.  You
should have somewhere before the pg_exec a line like:
$database=pg_connect("dbname=your_db user=your_user");

The error that displays is not the cause of the error, it is back up in
the code that you need to look.

Hopefully you will find the missing or wrong piece up there.
It is also a good practice to include lots of error checks in your
program to help isolate where things are going wrong.  It is also good
not to make typing errors when writing error checks  :-[  as I did.

HTH
Paul

Yasmine Kedoo wrote:

> Hey Paul.
>
> I've actually used CHAR for the id, as it involves both numbers and
> letters. That's y i actually left the single inverted commas around
> $adid, '$adid'.
>
> So i too am confused as to why the code doesn't work. Can't put my
> finger on the problem at the mo, but still get the same error.
>
> Warning: Unable to jump to row 0 on PostgreSQL result index 2 in
> /home/webpages/yamkedoo/Project/updaad.php on line 66
>
> I've added ur suggestion, but still the same thing. If u could help
> any further, that would be great :-)
>
> Thanx again,
>
> Yasmine
>
>
>
>
>
>
>> From: Paul Lynch <paul.lynch@exemail.com.au>
>> To: pgsql-php@postgresql.org
>> Subject: Re: [PHP] Parsing Data, Table to Form
>> Date: Mon, 17 May 2004 22:21:00 +1000
>>
>> Hi Yasmine,
>>
>> A lack of error checking has caught us out here. Plus some syntax in
>> the select and where clause.  The adid in admininfo table is an
>> integer, and I gave you code for using a character type key. So
>> change ... WHERE adid='$adid'   to  WHERE adid=$adid    (drop the ' )
>> While there you could add some error condition checking like below:
>>
>> $rowtoupdate = pg_exec($database, "SELECT adid, name, sur, phone,
>> email, username, password, building, postcode                 FROM
>> admininfo WHERE adid=$adid");
>> if ( ! pg_numrows($rowstoupdate) == 1 )          // expecting a
>> single row only
>> {
>>       echo "<h2>Error in getting information from table</h2>";
>>       // add whatever you want here to help you see what went wrong
>> } else{
>>        list($formadid, $formname, $formsurname, $formphone,
>> $formemail, $formusername,
>> $formpassword,
>> $formbuilding,$formpostcode) = pg_fetch_row($rowtoupdate, 0);
>> }
>>
>> Keep going you're getting close.
>>


pgsql-php by date:

Previous
From: "Scot L. Harris"
Date:
Subject: Re: table column information
Next
From: Lynna Landstreet
Date:
Subject: Re: Sessions and serializing (was: Checking data inserted