Re: Parsing Data, Table to Form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.


Yasmine Kedoo wrote:

Hey Paul.

Yes, the error is exactly that :-). I've put in the following code on admininfo.php:

else
            {

                $row = pg_fetch_object($result, 0);

                $test = "";

                   for ($rw = 0; $rw < $maxrows; $rw++)
                   {

                    echo " <tr> ";

                    for ($fld = 0; $fld < $maxfields ; $fld++)

                    {


/*echo "<td width=\"418\" class=\"tabletext\" height=\"38\">";


                        echo "</td>";
                        echo $test .= pg_Result($result,$rw,$fld);*/

                        echo pg_Result($result,$rw,$fld);

                    }

/*echo "<td width=\"194\" class=\"tabletext\" height=\"38\"> </td> </tr>";*/


                    pg_result($result,0,$adid);
                    echo "<form method=post action=updaad.php>\n";
echo "<input type=\"hidden\" name=\"adid\"value=\"$adid\" >"; echo "<input type=\"hidden\" name=\"name\"value=\"$name\" >"; echo "<input type=\"hidden\" name=\"surname\"value=\"$surname\" >"; echo "<input type=\"hidden\" name=\"phone\"value=\"$phone\" >"; echo "<input type=\"hidden\" name=\"email\"value=\"$email\" >"; echo "<input type=\"hidden\" name=\"username\"value=\"$username\" >"; echo "<input type=\"hidden\" name=\"password\"value=\"$password\" >"; echo "<input type=\"hidden\" name=\"building\"value=\"$building\" >"; echo "<input type=\"hidden\" name=\"postcode\"value=\"$postcode\" >";
                    echo "<input type=\"submit\" value=\"Update\" >";
                    echo "</form>";
                   }
            }

and on page updaad.php, the error:

Warning: Unable to jump to row 0 on PostgreSQL result index 2 in /home/webpages/yamkedoo/Project/updaad.php on line 66

is displayed, along with empty textfields. The relevant code for updaad.php is as follows:

                                               $adid =  $_POST['adid'];
            $name =  $_POST['name'];
            $surname =  $_POST['surname'];
            $phone =  $_POST['phone'];
            $email =  $_POST['email'];
            $username =  $_POST['username'];
            $password =  $_POST['password'];
            $building =  $_POST['building'];
            $postcode =  $_POST['postcode'];

$rowtoupdate = pg_exec($database, "SELECT adid, name, sur, phone, email, username, password, building, postcode FROM admininfo WHERE adid='$adid'");

list($formadid, $formname, $formsurname, $formphone, $formemail, $formusername, $formpassword, $formbuilding,$formpostcode) = pg_fetch_row($rowtoupdate, 0);

            echo "<form method=post action=adupdate.php>\n";
echo "Admin ID Number: <input type=text name=\"formadid\" value=\"$formadid\"><br />\n"; echo "Name: <input type=text name=\"formname\" value=\"$formname\"><br />\n"; echo "Surname: <input type=text name=\"formsurname\" value=\"$formsurname\"><br />\n"; echo "Phone: <input type=text name=\"formphone\" value=\"$formphone\"><br />\n"; echo "Email: <input type=text name=\"formemail\" value=\"$formemail\"><br />\n"; echo "Username: <input type=text name=\"formusername\" value=\"$formusername\"><br />\n"; echo "Password: <input type=text name=\"formpassword\" value=\"$formpassword\"><br />\n"; echo "Building: <input type=text name=\"formbuilding\" value=\"$formbuilding\"><br />\n"; echo "Postcode: <input type=text name=\"formpostcode\" value=\"$formpostcode\"><br />\n";
            echo "<BR>";
            echo "<input type=\"submit\" value=\"Update\" >";
            echo "</form>";

I am not too sure how to fix the error on page admininfo.php. Any ideas? It doesn't seem to be parsing the data to the textfields.

Thanx again,

Yasmine


From: Paul Lynch <paul.lynch@xxxxxxxxxxxxxx>
To: Yasmine Kedoo <yazkedoo@xxxxxxxxxxx>,  pgsql-php@xxxxxxxxxxxxxx
Subject: Re: [PHP] Parsing Data, Table to Form
Date: Sun, 16 May 2004 22:14:15 +1000

Hi Yasmine,

Could you post line 66 or point out which line is 66 in updaad.php. From the error message I would expect it to contain something like:
pg_fetch_row($rowtoupdate, 0)

From your code, if this failed it would be before the display of data in the form, and not after you click the update button. Which has me a little perplexed. In fact I would expect clicking on the update button to start loading program adupdate.php
as per instructions in this line:
 echo "<form method=post action=adupdate.php>\n";
So unless this error was hidden somehow by the form and then displayed after the click of update button, but that doesn't fit with my knowledge of browser behaviour.

I am hoping the content on line 66 and a bit above and below it can help relate the error message to the code.

Paul

Yasmine Kedoo wrote:

but when i click the submit button on updaad.php, i'm getting the following error :

Warning: Unable to jump to row 0 on PostgreSQL result index 2 in /home/webpages/yamkedoo/Project/updaad.php on line 66

and nothing is being parsed to the textfields on adupdate.php (writeat.php).

Do u know wat the problem may be? :-)

Thanx again, your help is much appreciated

Yasmine




_________________________________________________________________
Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger






[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux