Re: UPDATE - Changing Password - Mailing list pgsql-php

From Robby Russell
Subject Re: UPDATE - Changing Password
Date
Msg-id 4083E148.1030807@commandprompt.com
Whole thread Raw
In response to Re: UPDATE - Changing Password  ("Yasmine Kedoo" <yazkedoo@hotmail.com>)
List pgsql-php
Yasmine Kedoo typed this on 04/18/2004 02:23 AM:
> Hi.
>
> I have changed the code as suggested, but still no luck, and a new
> error. The error is:
>
> Fatal error: Call to undefined function: pg_affected_rows() in
> /home/webpages/yamkedoo/Tests/chpw1.php on line 55
>
> I used the following code:
>
> if(!$database)
>         {
>            echo "Connection Failed<BR>";
>         exit;
>         }
>
>     else
>     {
>         $gdidno = addslashes(trim($formgpid));
>         $newpw = addslashes(trim($formnewpw));
>         $newpw1 = addslashes(trim($formnewpw1));
>
>         $query = "UPDATE gpinfo SET password='$newpw' WHERE
> gpid='$gpidno'";
>         $result = pg_exec($database, $query);
>
>         if(!$result)
>         {
>             print "There was a problem accessing the database";
>             exit;
>         }
>         else if(pg_affected_rows($result)!=1)
>         {
>             print "Update Failed\n";
>             exit;
>         }
>         else if($result)
>         {
>
>             print "Update Successful\n<BR>";
>
>         }
>     }
>
>
> I tried removing this section of the code:  else
> if(pg_affected_rows($result)!=1)
>                                   {
>                        print "Update Failed\n";
>                        exit;
>                                    }
>
> as this is where the error is, then got "Update Successful", but the
> password had not been updated.
>
> Any ideas?
>
> Yasmine
>


After you set the variable $query, print it out.

>
>         $query = "UPDATE gpinfo SET password='$newpw' WHERE gpid='$gpidno'";
print "My Query: " . $query;

>         $result = pg_exec($database, $query);

What does it print out? Then try copying that and running it directly in
postgresql. If your query is failing, you can debug it that way.

-Robby

--
Robby Russell,  |  Sr. Administrator / Lead Programmer
Command Prompt, Inc.   |  http://www.commandprompt.com
rrussell@commandprompt.com | Telephone: (503) 667.4564

pgsql-php by date:

Previous
From: Keary Suska
Date:
Subject: Re: UPDATE - Changing Password
Next
From: Adam Witney
Date:
Subject: Uploading and parsing a file into a table