UPDATE - Changing Password

UPDATE - Changing Password

am 17.04.2004 23:28:03 von Yasmine Kedoo

Hi.

Does anyone know how to use UPDATE with PHP for changing a password? I've
tried the following code:

$query = "UPDATE patperinfo SET trim(password)='$newpw' WHERE
trim(gpid)='$gpidno'";
$result = pg_exec($database, $query);

where new $newpw & $gpidno are the values entered into a form then passed to
the script.

I get the following error:

Warning: PostgreSQL query failed: ERROR: parser: parse error at or near "("
at character 27 in /home/webpages/yamkedoo/Tests/chpw1.php on line 48

where the error is on the line: $result = pg_exec($database, $query);

Thanx :-)

____________________________________________________________ _____
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Re: UPDATE - Changing Password

am 17.04.2004 23:40:24 von Robby Russell

Yasmine Kedoo typed this on 04/17/2004 02:28 PM:
> Hi.
>
> Does anyone know how to use UPDATE with PHP for changing a password?
> I've tried the following code:
>
> $query = "UPDATE patperinfo SET trim(password)='$newpw' WHERE
> trim(gpid)='$gpidno'";
> $result = pg_exec($database, $query);
>
> where new $newpw & $gpidno are the values entered into a form then
> passed to the script.
>
> I get the following error:
>
> Warning: PostgreSQL query failed: ERROR: parser: parse error at or near
> "(" at character 27 in /home/webpages/yamkedoo/Tests/chpw1.php on line 48
>
> where the error is on the line: $result = pg_exec($database, $query);
>
>

$query = "UPDATE tablename SET password = '$newpw' WHERE ...

I don't know why you'd trim a fieldname while setting it.

-Robby

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Re: UPDATE - Changing Password

am 17.04.2004 23:57:43 von Robby Russell

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@commandprompt.com | Telephone: (503) 667.4564

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: UPDATE - Changing Password

am 18.04.2004 00:18:00 von Yasmine Kedoo

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
";

}
}

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
>To: Yasmine Kedoo , pgsql-php@postgresql.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@commandprompt.com | Telephone: (503) 667.4564
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.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

Re: UPDATE - Changing Password

am 18.04.2004 11:23:10 von Yasmine Kedoo

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
";
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
";

}
}


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"
>To: "Yasmine Kedoo"
>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"
>To:
>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
";
> >
> > }
> > }
> >
> > 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
> > >To: Yasmine Kedoo , pgsql-php@postgresql.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@commandprompt.com | Telephone: (503) 667.4564
> > >
> > >---------------------------(end of
>broadcast)---------------------------
> > >TIP 3: if posting/reading through Usenet, please send an appropriate
> > > subscribe-nomail command to majordomo@postgresql.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


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: UPDATE - Changing Password

am 18.04.2004 19:35:08 von Keary Suska

on 4/18/04 3:23 AM, yazkedoo@hotmail.com purportedly said:

> Fatal error: Call to undefined function: pg_affected_rows() in
> /home/webpages/yamkedoo/Tests/chpw1.php on line 55

This means that you are using a PHP version < 4.2.0 . Use pg_cmdtuples()
instead.

> 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.

In this case, this just means that the query is either failing or not being
committed. 1) verify that the query should execute successfully--i.e. have
your script output the $query value and then use that in the command line
interface; 2) is the query executing in a transaction? There may be server
configurations forcing the issue. To make sure, send "COMMIT" before closing
the Db connection or ending the script. If you get a "no transaction" error,
then this isn't the problem.

Best regards,

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Re: UPDATE - Changing Password

am 19.04.2004 16:25:12 von Robby Russell

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
";
> 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
";
>
> }
> }
>
>
> 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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Re: UPDATE - Changing Password

am 20.04.2004 10:20:33 von Yasmine Kedoo

Hey.

I'd like to thank everyone who helped me. I was able to fix the code by
printing the query to c wat was wrong, and also, pg_cmdtuples( ) was very
useful :-).

Does anybody know how to find out what version of PHP i may be running?

Thanx Again

Yasmine



>From: "Peter Bayley"
>To: "Yasmine Kedoo"
>Subject: Re: [PHP] UPDATE - Changing Password
>Date: Tue, 20 Apr 2004 13:27:01 +1000
>
>Hi Yasmine
>
>As someone else has already noted, you must be running an early version of
>PHP which doesn't have the pg_affected_rows function.
>
>The older equivalent function is pg_cmdtuples() so you should change your
>code to use the older function
>
>ie:
>
>$result=pg_exec($database, "update gpinfo set password='$newpw' where
>gpid='$gpidno'");
>if (!$result) {
> print "There was a problem accessing the database
>[".pg_errormessage($database)."]\n";
> exit;
>}
>if(pg_cmdtuples($result) !=1 ) {
> print "Update Failed: (".pg_cmdtuples($result)." rows were affected)\n";
> exit;
>}
>print "Update Successful\n
";
>
>Regards
>
>Peter
>
>----- Original Message -----
>From: "Yasmine Kedoo"
>To:
>Sent: Sunday, April 18, 2004 7:23 PM
>Subject: Re: [PHP] UPDATE - Changing Password
>
>
> > 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
";
> > 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
";
> >
> > }
> > }
> >
> >
> > 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"
> > >To: "Yasmine Kedoo"
> > >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"
> > >To:
> > >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
";
> > > >
> > > > }
> > > > }
> > > >
> > > > 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
> > > > >To: Yasmine Kedoo , pgsql-php@postgresql.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@commandprompt.com | Telephone: (503) 667.4564
> > > > >
> > > > >---------------------------(end of
> > >broadcast)---------------------------
> > > > >TIP 3: if posting/reading through Usenet, please send an
>appropriate
> > > > > subscribe-nomail command to majordomo@postgresql.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
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >

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


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: UPDATE - Changing Password

am 20.04.2004 10:36:05 von Viorel Dragomir

This is a multi-part message in MIME format.

------=_NextPart_000_017B_01C426CB.AA45E360
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

View a test page with only this function within:
phpinfo();
?>

Cheers
----- Original Message -----=20
From: Yasmine Kedoo=20
To: pgsql-php@postgresql.org=20
Sent: Tuesday, April 20, 2004 11:20 AM
Subject: Re: [PHP] UPDATE - Changing Password


Hey.

I'd like to thank everyone who helped me. I was able to fix the code by=
=20
printing the query to c wat was wrong, and also, pg_cmdtuples( ) was very=
=20
useful :-).

Does anybody know how to find out what version of PHP i may be running?

Thanx Again

Yasmine



>From: "Peter Bayley"
>To: "Yasmine Kedoo"
>Subject: Re: [PHP] UPDATE - Changing Password
>Date: Tue, 20 Apr 2004 13:27:01 +1000
>
>Hi Yasmine
>
>As someone else has already noted, you must be running an early version =
of=20
>PHP which doesn't have the pg_affected_rows function.
>
>The older equivalent function is pg_cmdtuples() so you should change you=
r=20
>code to use the older function
>
>ie:
>
>$result=3Dpg_exec($database, "update gpinfo set password=3D'$newpw' wher=
e=20
>gpid=3D'$gpidno'");
>if (!$result) {
> print "There was a problem accessing the database=20
>[".pg_errormessage($database)."]\n";
> exit;
>}
>if(pg_cmdtuples($result) !=3D1 ) {
> print "Update Failed: (".pg_cmdtuples($result)." rows were affected)\=
n";
> exit;
>}
>print "Update Successful\n
";
>
>Regards
>
>Peter
>
>----- Original Message -----
>From: "Yasmine Kedoo"
>To:
>Sent: Sunday, April 18, 2004 7:23 PM
>Subject: Re: [PHP] UPDATE - Changing Password
>
>
> > Hi.
> >
> > I have changed the code as suggested, but still no luck, and a new=20
>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
";
> > exit;
> > }
> >
> > else
> > {
> > $gdidno =3D addslashes(trim($formgpid));
> > $newpw =3D addslashes(trim($formnewpw));
> > $newpw1 =3D addslashes(trim($formnewpw1));
> >
> > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE gpid=3D'$gpid=
no'";
> > $result =3D pg_exec($database, $query);
> >
> > if(!$result)
> > {
> > print "There was a problem accessing the database";
> > exit;
> > }
> > else if(pg_affected_rows($result)!=3D1)
> > {
> > print "Update Failed\n";
> > exit;
> > }
> > else if($result)
> > {
> >
> > print "Update Successful\n
";
> >
> > }
> > }
> >
> >
> > I tried removing this section of the code: else
> > if(pg_affected_rows($result)!=3D1)
> > {
> > 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"
> > >To: "Yasmine Kedoo"
> > >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) !=3D 1) {
> > > ...
> > >
> > >Regards
> > >
> > >Peter
> > >
> > >----- Original Message -----
> > >From: "Yasmine Kedoo"
> > >To:
> > >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 err=
or=20
>on
> > >my
> > > > part. But the update is still not working.
> > > >
> > > > I'm using the following script:
> > > >
> > > > else
> > > > {
> > > > $gdidno =3D addslashes(trim($formgpid));
> > > > $newpw =3D addslashes(trim($formnewpw));
> > > > /*$newpw1 =3D addslashes(trim($formnewpw1));*/
> > > >
> > > > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE gpid=3D'$=
gpidno'";
> > > > $result =3D pg_exec($database, $query);
> > > >
> > > >
> > > > if(!$result)
> > > > {
> > > > print "There was a problem accessing the database";
> > > > exit;
> > > > }
> > > > else if(pg_numrows($result)!=3D1)
> > > > {
> > > > print "Update Failed\n";
> > > > exit;
> > > > }
> > > > else
> > > > {
> > > >
> > > > print "Update Successful\n
";
> > > >
> > > > }
> > > > }
> > > >
> > > > It is just printing Update Failed now. Can u see where i'm going=
=20
>wrong?
> > > >
> > > > Visit the following link:=20
>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=
=20
>update
> > > > failed. Can u see the prob?
> > > >
> > > > Cheers
> > > >
> > > > >From: Robby Russell
> > > > >To: Yasmine Kedoo , pgsql-php@postgresql.o=
rg
> > > > >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@commandprompt.com | Telephone: (503) 667.4564
> > > > >
> > > > >---------------------------(end of
> > >broadcast)---------------------------
> > > > >TIP 3: if posting/reading through Usenet, please send an=20
>appropriate
> > > > > subscribe-nomail command to majordomo@postgresql.org so th=
at=20
>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=20
>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
> >
> >
> > ---------------------------(end of broadcast)------------------------=
---
> > TIP 4: Don't 'kill -9' the postmaster
> >

____________________________________________________________ _____
Use MSN Messenger to send music and pics to your friends=20
http://www.msn.co.uk/messenger


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
------=_NextPart_000_017B_01C426CB.AA45E360
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable








View a test page with only this function=
=20
within:

<?php

    phpinfo();

?>

 

Cheers

style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LE=
FT: #000000 2px solid; MARGIN-RIGHT: 0px">
----- Original Message -----

style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black">Fro=
m:
=20
Yasm=
ine=20
Kedoo

To: l.org=20
href=3D"mailto:pgsql-php@postgresql.org">pgsql-php@postgresq l.org
IV>
Sent: Tuesday, April 20, 2004 11:2=
0=20
AM

Subject: Re: [PHP] UPDATE - Changi=
ng=20
Password


Hey.

I'd like to thank everyone who helped me. I wa=
s=20
able to fix the code by
printing the query to c wat was wrong, and al=
so,=20
pg_cmdtuples( ) was very
useful :-).

Does anybody know how to =
find=20
out what version of PHP i may be running?

Thanx=20
Again

Yasmine



>From: "Peter Bayley" < href=3D"mailto:pbay6343@bigpond.net.au">pbay6343@bigpond.net .au> R>>To:=20
"Yasmine Kedoo" < href=3D"mailto:yazkedoo@hotmail.com">yazkedoo@hotmail.com>
>=
Subject:=20
Re: [PHP] UPDATE - Changing Password
>Date: Tue, 20 Apr 2004 13:27:=
01=20
+1000
>
>Hi Yasmine
>
>As someone else has alread=
y=20
noted, you must be running an early version of
>PHP which doesn't =
have=20
the pg_affected_rows function.
>
>The older equivalent functi=
on is=20
pg_cmdtuples() so you should change your
>code to use the older=20
function
>
>ie:
>
>$result=3Dpg_exec($database, "=
update=20
gpinfo set password=3D'$newpw' where
>gpid=3D'$gpidno'");
>i=
f=20
(!$result) {
>   print "There was a problem accessing the=
=20
database
>[".pg_errormessage($database)."]\n";
>  =
=20
exit;
>}
>if(pg_cmdtuples($result) !=3D1 ) {
> &nb=
sp;=20
print "Update Failed: (".pg_cmdtuples($result)." rows were=20
affected)\n";
>   exit;
>}
>print "Update=20
Successful\n<br>";
>
>Regards
>
>Peter
&=
gt;
>-----=20
Original Message -----
>From: "Yasmine Kedoo" < href=3D"mailto:yazkedoo@hotmail.com">yazkedoo@hotmail.com>
>=
To:=20
< href=3D"mailto:pgsql-php@postgresql.org">pgsql-php@postgresq l.org>=

>Sent:=20
Sunday, April 18, 2004 7:23 PM
>Subject: Re: [PHP] UPDATE - Changin=
g=20
Password
>
>
> > Hi.
> >
> > I hav=
e=20
changed the code as suggested, but still no luck, and a new=20

>error.
> > The error is:
> >
> > Fatal=
=20
error: Call to undefined function: pg_affected_rows() in
> >=20
/home/webpages/yamkedoo/Tests/chpw1.php on line 55
> >
> &=
gt; I=20
used the following code:
> >
> > if(!$database)
>=
=20
>      {
>=20
>         echo "Connection=20
Failed<BR>";
> > exit;
>=20
>      }
> >
> > else
&g=
t;=20
> {
> > $gdidno =3D addslashes(trim($formgpid));
> >=
$newpw=20
=3D addslashes(trim($formnewpw));
> > $newpw1 =
addslashes(trim($formnewpw1));
> >
> > $query =3D "UPDA=
TE=20
gpinfo SET password=3D'$newpw' WHERE gpid=3D'$gpidno'";
> > $res=
ult =
pg_exec($database, $query);
> >
> > if(!$result)
>=
;=20
> {
> > print "There was a problem accessing the=20
database";
> > exit;
> > }
> > else=20
if(pg_affected_rows($result)!=3D1)
> > {
> > print "Upd=
ate=20
Failed\n";
> > exit;
> > }
> > else=20
if($result)
> > {
> >
> > print "Update=20
Successful\n<BR>";
> >
> > }
> > }
&g=
t;=20
>
> >
> > I tried removing this section of the=20
code:  else
> > if(pg_affected_rows($result)!=3D1)
>=
=20
>           &nb=
sp;            =
  =20
{
>=20
>            pr=
int=20
"Update Failed\n";
>=20
>           =20
exit;
>=20
>           &nb=
sp;            =
   =20
}
> >
> > as this is where the error is, then got "Upda=
te=20
Successful", but the
> > password had not been updated.
>=
=20
>
> > Any ideas?
> >
> > Yasmine
>=20
>
> >
> >
> >
> >
> >
=
>=20
>
> > >From: "Peter Bayley" < href=3D"mailto:pbay6343@bigpond.net.au">pbay6343@bigpond.net .au> R>>=20
> >To: "Yasmine Kedoo" < href=3D"mailto:yazkedoo@hotmail.com">yazkedoo@hotmail.com>
>=
>=20
>Subject: Re: [PHP] UPDATE - Changing Password
> > >Date: =
Sun,=20
18 Apr 2004 17:28:18 +1000
> > >
> > >Hi=20
Yasmine,
> > >
> > >An update will not return row=
s=20
from the query so pg_num_rows will be 0.
> > >You
> >=
;=20
>should use pg_affected_rows as in..
> > >
> >=20
>     if (pg_affected_rows($result) !=3D 1) {
&=
gt;=20
> >         ...
> >=
;=20
>
> > >Regards
> > >
> > >Peter >>=20
> >
> > >----- Original Message -----
> > >=
From:=20
"Yasmine Kedoo" < href=3D"mailto:yazkedoo@hotmail.com">yazkedoo@hotmail.com>
>=
>=20
>To: < href=3D"mailto:pgsql-php@postgresql.org">pgsql-php@postgresq l.org>=

>=20
> >Sent: Sunday, April 18, 2004 8:18 AM
> > >Subject: R=
e:=20
[PHP] UPDATE - Changing Password
> > >
> > >
&=
gt;=20
> > > Hi.
> > > >
> > > > I think =
i've=20
sorted the previous problem now, it was a stupid error
>on
>=
>=20
>my
> > > > part. But the update is still not=20
working.
> > > >
> > > > I'm using the foll=
owing=20
script:
> > > >
> > > > else
> > &=
gt;=20
> {
> > > > $gdidno =3D addslashes(trim($formgpid)); >>=20
> > > $newpw =3D addslashes(trim($formnewpw));
> > >=
>=20
/*$newpw1 =3D addslashes(trim($formnewpw1));*/
> > > >
=
>=20
> > > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE=20
gpid=3D'$gpidno'";
> > > > $result =3D pg_exec($database,=
=20
$query);
> > > >
> > > >
> > > =
>=20
if(!$result)
> > > > {
> > > > print "There=
was=20
a problem accessing the database";
> > > > exit;
> &=
gt;=20
> > }
> > > > else if(pg_numrows($result)!=3D1)
&=
gt;=20
> > > {
> > > > print "Update Failed\n";
> =
>=20
> > exit;
> > > > }
> > > > else
&=
gt;=20
> > > {
> > > >
> > > > print "Upd=
ate=20
Successful\n<BR>";
> > > >
> > > >=20
}
> > > > }
> > > >
> > > > =
It is=20
just printing Update Failed now. Can u see where i'm going=20

>wrong?
> > > >
> > > > Visit the=20
following link:
>www.cyber.brad.ac.uk/~yamkedoo/Tests/chpw.html >>=20
> > >
> > > > Username: jjsanderson
> > =
>=20
> Password: sanderso
> > > >
> > > > The=
n on=20
the next page, GP ID: GP000001
> > >=20
>           &nb=
sp;            =
           =20
New Password: hello
> > > >
> > > > and ign=
ore=20
retype password for now. As u can see, it is printing
>update
&=
gt;=20
> > > failed. Can u see the prob?
> > > >
>=
>=20
> > Cheers
> > > >
> > > > >From: =
Robby=20
Russell < href=3D"mailto:rrussell@commandprompt.com">rrussell@commandp rompt.com=
>
>=20
> > > >To: Yasmine Kedoo < href=3D"mailto:yazkedoo@hotmail.com">yazkedoo@hotmail.com>, href=3D"mailto:pgsql-php@postgresql.org">pgsql-php@postgresq l.org
=
>=20
> > > >Subject: Re: [PHP] UPDATE - Changing Password
> =
>=20
> > >Date: Sat, 17 Apr 2004 14:57:43 -0700
> > > >=
;=20
>
> > > > >Yasmine Kedoo typed this on 04/17/2004 02=
:48=20
PM:
> > > > >>Hi Robby.
> > > >=20
>>
> > > > >>That was recommended to me by som=
eone=20
else :)
> > > > >>
> > > > >>Wh=
en i=20
remove the trim, i still get the same problem.
> > > >=20
>>
> > > > >>Any other ideas?
> > >=
;=20
> >>
> > > > >
> > > > >Are =
you=20
getting the same exact error at the same exact character in
> >=
=20
>your
> > > > >query? Send me your error and I'll he=
lp=20
you more.
> > > > >
> > > > >Robby >>=20
> > > >
> > > > >--
> > > >=
=20
>Robby Russell,  |  Sr. Administrator / Lead Programmer
&=
gt;=20
> > > >Command Prompt, Inc.   |  href=3D"http://www.commandprompt.com">http://www.commandprom pt.com >>=20
> > > >rrussell@commandprompt.com | Telephone: (503)=20
667.4564
> > > > >
> > > >=20
>---------------------------(end of
> >=20
>broadcast)---------------------------
> > > > >TIP =
3: if=20
posting/reading through Usenet, please send an
>appropriate
>=
;=20
> > > >      subscribe-nomail comman=
d to=20
=
so that=20

>your
> > > > >      me=
ssage=20
can get through to the mailing list cleanly
> > > >
>=
;=20
> > >=20
____________________________________________________________ _____
>=
>=20
> > Express yourself with cool new emoticons
> >=20
>http://www.msn.co.uk/specials/myemo
> > > >
> &g=
t;=20
> >
> > > > ---------------------------(end of=20

>broadcast)---------------------------
> > > > TIP =
6:=20
Have you searched our list archives?
> > > >
> > =
>=20
>           &nb=
sp;   =20
href=3D"http://archives.postgresql.org">http://archives.post gresql.org >
>=20
> > >
> > >
> >
> >=20
____________________________________________________________ _____
>=
>=20
It's fast, it's easy and it's free. Get MSN Messenger today!
> >=
href=3D"http://www.msn.co.uk/messenger">http://www.msn.co.uk /messenger >
>=20
>
> >
> > ---------------------------(end of=20
broadcast)---------------------------
> > TIP 4: Don't 'kill -9'=
the=20
postmaster
>=20
>

____________________________________________________________ _=
____
Use=20
MSN Messenger to send music and pics to your friends
href=3D"http://www.msn.co.uk/messenger">http://www.msn.co.uk /messenger >


---------------------------(end=20
of broadcast)---------------------------
TIP 3: if posting/reading thr=
ough=20
Usenet, please send an appropriate
     =20
subscribe-nomail command to href=3D"mailto:majordomo@postgresql.org">majordomo@postgresq l.org so =
that=20
your
      message can get through to the mai=
ling=20
list cleanly

------=_NextPart_000_017B_01C426CB.AA45E360--

Re: UPDATE - Changing Password

am 20.04.2004 10:37:05 von Adam Witney

Hi Yasmine,

One way to find out all about your PHP installation is to save this as a
script (php_info.php):



PHP server info






Then put it somewhere accessible from your web server and load it up in your
browser

Cheers

dam


> Hey.
>
> I'd like to thank everyone who helped me. I was able to fix the code by
> printing the query to c wat was wrong, and also, pg_cmdtuples( ) was very
> useful :-).
>
> Does anybody know how to find out what version of PHP i may be running?
>
> Thanx Again
>
> Yasmine
>
>
>
>> From: "Peter Bayley"
>> To: "Yasmine Kedoo"
>> Subject: Re: [PHP] UPDATE - Changing Password
>> Date: Tue, 20 Apr 2004 13:27:01 +1000
>>
>> Hi Yasmine
>>
>> As someone else has already noted, you must be running an early version of
>> PHP which doesn't have the pg_affected_rows function.
>>
>> The older equivalent function is pg_cmdtuples() so you should change your
>> code to use the older function
>>
>> ie:
>>
>> $result=pg_exec($database, "update gpinfo set password='$newpw' where
>> gpid='$gpidno'");
>> if (!$result) {
>> print "There was a problem accessing the database
>> [".pg_errormessage($database)."]\n";
>> exit;
>> }
>> if(pg_cmdtuples($result) !=1 ) {
>> print "Update Failed: (".pg_cmdtuples($result)." rows were affected)\n";
>> exit;
>> }
>> print "Update Successful\n
";
>>
>> Regards
>>
>> Peter
>>
>> ----- Original Message -----
>> From: "Yasmine Kedoo"
>> To:
>> Sent: Sunday, April 18, 2004 7:23 PM
>> Subject: Re: [PHP] UPDATE - Changing Password
>>
>>
>>> 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
";
>>> 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
";
>>>
>>> }
>>> }
>>>
>>>
>>> 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"
>>>> To: "Yasmine Kedoo"
>>>> 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"
>>>> To:
>>>> 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
";
>>>>>
>>>>> }
>>>>> }
>>>>>
>>>>> 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
>>>>>> To: Yasmine Kedoo , pgsql-php@postgresql.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@commandprompt.com | Telephone: (503) 667.4564
>>>>>>
>>>>>> ---------------------------(end of
>>>> broadcast)---------------------------
>>>>>> TIP 3: if posting/reading through Usenet, please send an
>> appropriate
>>>>>> subscribe-nomail command to majordomo@postgresql.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
>>>
>>>
>>> ---------------------------(end of broadcast)---------------------------
>>> TIP 4: Don't 'kill -9' the postmaster
>>>
>
> ____________________________________________________________ _____
> Use MSN Messenger to send music and pics to your friends
> http://www.msn.co.uk/messenger
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: UPDATE - Changing Password

am 20.04.2004 11:10:00 von nasir

Or just run php4 from command line
nasir@debian:/home/vhosts$ php4 -v
4.2.1

> View a test page with only this function within:
> > phpinfo();
> ?>
>
> Cheers
> ----- Original Message -----
> From: Yasmine Kedoo
> To: pgsql-php@postgresql.org
> Sent: Tuesday, April 20, 2004 11:20 AM
> Subject: Re: [PHP] UPDATE - Changing Password
>
>
> Hey.
>
> I'd like to thank everyone who helped me. I was able to fix the code
> by printing the query to c wat was wrong, and also, pg_cmdtuples( )
> was very useful :-).
>
> Does anybody know how to find out what version of PHP i may be
> running?
>
> Thanx Again
>
> Yasmine
>
>
>
> >From: "Peter Bayley"
> >To: "Yasmine Kedoo"
> >Subject: Re: [PHP] UPDATE - Changing Password
> >Date: Tue, 20 Apr 2004 13:27:01 +1000
> >
> >Hi Yasmine
> >
> >As someone else has already noted, you must be running an early
> >version of PHP which doesn't have the pg_affected_rows function.
> >
> >The older equivalent function is pg_cmdtuples() so you should change
> >your code to use the older function
> >
> >ie:
> >
> >$result=3Dpg_exec($database, "update gpinfo set password=3D'$newpw' w=
here
> > gpid=3D'$gpidno'");
> >if (!$result) {
> > print "There was a problem accessing the database
> >[".pg_errormessage($database)."]\n";
> > exit;
> >}
> >if(pg_cmdtuples($result) !=3D1 ) {
> > print "Update Failed: (".pg_cmdtuples($result)." rows were
> > affected)\n"; exit;
> >}
> >print "Update Successful\n
";
> >
> >Regards
> >
> >Peter
> >
> >----- Original Message -----
> >From: "Yasmine Kedoo"
> >To:
> >Sent: Sunday, April 18, 2004 7:23 PM
> >Subject: Re: [PHP] UPDATE - Changing Password
> >
> >
> > > 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
";
> > > exit;
> > > }
> > >
> > > else
> > > {
> > > $gdidno =3D addslashes(trim($formgpid));
> > > $newpw =3D addslashes(trim($formnewpw));
> > > $newpw1 =3D addslashes(trim($formnewpw1));
> > >
> > > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE
> > > gpid=3D'$gpidno'"; $result =3D pg_exec($database, $query);
> > >
> > > if(!$result)
> > > {
> > > print "There was a problem accessing the database";
> > > exit;
> > > }
> > > else if(pg_affected_rows($result)!=3D1)
> > > {
> > > print "Update Failed\n";
> > > exit;
> > > }
> > > else if($result)
> > > {
> > >
> > > print "Update Successful\n
";
> > >
> > > }
> > > }
> > >
> > >
> > > I tried removing this section of the code: else
> > > if(pg_affected_rows($result)!=3D1)
> > > {
> > > 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"
> > > >To: "Yasmine Kedoo"
> > > >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) !=3D 1) {
> > > > ...
> > > >
> > > >Regards
> > > >
> > > >Peter
> > > >
> > > >----- Original Message -----
> > > >From: "Yasmine Kedoo"
> > > >To:
> > > >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 =3D addslashes(trim($formgpid));
> > > > > $newpw =3D addslashes(trim($formnewpw));
> > > > > /*$newpw1 =3D addslashes(trim($formnewpw1));*/
> > > > >
> > > > > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE
> > > > > gpid=3D'$gpidno'"; $result =3D pg_exec($database, $query);
> > > > >
> > > > >
> > > > > if(!$result)
> > > > > {
> > > > > print "There was a problem accessing the database";
> > > > > exit;
> > > > > }
> > > > > else if(pg_numrows($result)!=3D1)
> > > > > {
> > > > > print "Update Failed\n";
> > > > > exit;
> > > > > }
> > > > > else
> > > > > {
> > > > >
> > > > > print "Update Successful\n
";
> > > > >
> > > > > }
> > > > > }
> > > > >
> > > > > 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
> > > > > >To: Yasmine Kedoo ,
> > > > > >pgsql-php@postgresql.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@commandprompt.com | Telephone: (503) 667.4564
> > > > > >
> > > > > >---------------------------(end of
> > > >broadcast)---------------------------
> > > > > >TIP 3: if posting/reading through Usenet, please send an
> >appropriate
> > > > > > subscribe-nomail command to majordomo@postgresql.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
> > >
> > >
> > > ---------------------------(end of
> > > broadcast)--------------------------- TIP 4: Don't 'kill -9' the
> > > postmaster
> > >
>
> ____________________________________________________________ _____ Use
> MSN Messenger to send music and pics to your friends
> http://www.msn.co.uk/messenger
>
>
> ---------------------------(end of
> broadcast)--------------------------- TIP 3: if posting/reading
> through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that
> your message can get through to the mailing list cleanly




---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster