Skip site navigation (1) Skip section navigation (2)

Re: UPDATE - Changing Password

From: "Yasmine Kedoo" <yazkedoo(at)hotmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: UPDATE - Changing Password
Date: 2004-04-18 09:23:10
Message-ID: BAY14-F31cyJw78vrKa0005a58a@hotmail.com (view raw or flat)
Thread:
Lists: pgsql-php
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







>From: "Peter Bayley" <pbay6343(at)bigpond(dot)net(dot)au>
>To: "Yasmine Kedoo" <yazkedoo(at)hotmail(dot)com>
>Subject: Re: [PHP] UPDATE - Changing Password
>Date: Sun, 18 Apr 2004 17:28:18 +1000
>
>Hi Yasmine,
>
>An update will not return rows from the query so pg_num_rows will be 0.  
>You
>should use pg_affected_rows as in..
>
>     if (pg_affected_rows($result) != 1) {
>         ...
>
>Regards
>
>Peter
>
>----- Original Message -----
>From: "Yasmine Kedoo" <yazkedoo(at)hotmail(dot)com>
>To: <pgsql-php(at)postgresql(dot)org>
>Sent: Sunday, April 18, 2004 8:18 AM
>Subject: Re: [PHP] UPDATE - Changing Password
>
>
> > Hi.
> >
> > I think i've sorted the previous problem now, it was a stupid error on 
>my
> > part. But the update is still not working.
> >
> > I'm using the following script:
> >
> > 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_numrows($result)!=1)
> > {
> > print "Update Failed\n";
> > exit;
> > }
> > else
> > {
> >
> > print "Update Successful\n<BR>";
> >
> > }
> > }
> >
> > It is just printing Update Failed now. Can u see where i'm going wrong?
> >
> > Visit the following link: www.cyber.brad.ac.uk/~yamkedoo/Tests/chpw.html
> >
> > Username: jjsanderson
> > Password: sanderso
> >
> > Then on the next page, GP ID: GP000001
> >                                    New Password: hello
> >
> > and ignore retype password for now. As u can see, it is printing update
> > failed. Can u see the prob?
> >
> > Cheers
> >
> > >From: Robby Russell <rrussell(at)commandprompt(dot)com>
> > >To: Yasmine Kedoo <yazkedoo(at)hotmail(dot)com>, pgsql-php(at)postgresql(dot)org
> > >Subject: Re: [PHP] UPDATE - Changing Password
> > >Date: Sat, 17 Apr 2004 14:57:43 -0700
> > >
> > >Yasmine Kedoo typed this on 04/17/2004 02:48 PM:
> > >>Hi Robby.
> > >>
> > >>That was recommended to me by someone else :)
> > >>
> > >>When i remove the trim, i still get the same problem.
> > >>
> > >>Any other ideas?
> > >>
> > >
> > >Are you getting the same exact error at the same exact character in 
>your
> > >query? Send me your error and I'll help you more.
> > >
> > >Robby
> > >
> > >--
> > >Robby Russell,  |  Sr. Administrator / Lead Programmer
> > >Command Prompt, Inc.   |  http://www.commandprompt.com
> > >rrussell(at)commandprompt(dot)com | Telephone: (503) 667.4564
> > >
> > >---------------------------(end of 
>broadcast)---------------------------
> > >TIP 3: if posting/reading through Usenet, please send an appropriate
> > >      subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > >      message can get through to the mailing list cleanly
> >
> > _________________________________________________________________
> > Express yourself with cool new emoticons
>http://www.msn.co.uk/specials/myemo
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> >                http://archives.postgresql.org
> >
>

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger


Responses

pgsql-php by date

Next:From: Keary SuskaDate: 2004-04-18 17:35:08
Subject: Re: UPDATE - Changing Password
Previous:From: Yasmine KedooDate: 2004-04-17 22:18:00
Subject: Re: UPDATE - Changing Password

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group