UPDATE - Changing Password

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 [at] postgresql.org)
Yasmine Kedoo [ Sa, 17 April 2004 23:28 ] [ ID #141727 ]

Re: UPDATE - Changing Password

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Robby Russell [ Sa, 17 April 2004 23:40 ] [ ID #141728 ]

Re: UPDATE - Changing Password

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.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.org so that your
message can get through to the mailing list cleanly
Robby Russell [ Sa, 17 April 2004 23:57 ] [ ID #141729 ]

Re: 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.com>
>To: Yasmine Kedoo <yazkedoo [at] hotmail.com>, pgsql-php [at] 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 [at] 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 [at] 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
Yasmine Kedoo [ So, 18 April 2004 00:18 ] [ ID #141730 ]

Re: 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<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.net.au>
>To: "Yasmine Kedoo" <yazkedoo [at] hotmail.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.com>
>To: <pgsql-php [at] postgresql.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.com>
> > >To: Yasmine Kedoo <yazkedoo [at] hotmail.com>, pgsql-php [at] 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 [at] 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 [at] 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
Yasmine Kedoo [ So, 18 April 2004 11:23 ] [ ID #141731 ]

Re: UPDATE - Changing Password

on 4/18/04 3:23 AM, yazkedoo [at] 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
Keary Suska [ So, 18 April 2004 19:35 ] [ ID #141732 ]

Re: UPDATE - Changing Password

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Robby Russell [ Mo, 19 April 2004 16:25 ] [ ID #141733 ]

Re: 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" <pbay6343 [at] bigpond.net.au>
>To: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>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<br>";
>
>Regards
>
>Peter
>
>----- Original Message -----
>From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>To: <pgsql-php [at] postgresql.org>
>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<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.net.au>
> > >To: "Yasmine Kedoo" <yazkedoo [at] hotmail.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.com>
> > >To: <pgsql-php [at] postgresql.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.com>
> > > > >To: Yasmine Kedoo <yazkedoo [at] hotmail.com>, pgsql-php [at] 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 [at] 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 [at] 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 [at] postgresql.org so that your
message can get through to the mailing list cleanly
Yasmine Kedoo [ Di, 20 April 2004 10:20 ] [ ID #141735 ]

Re: UPDATE - Changing Password

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:
<?php
phpinfo();
?>

Cheers
----- Original Message -----
From: Yasmine Kedoo
To: pgsql-php [at] 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" <pbay6343 [at] bigpond.net.au>
>To: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>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 you=
r
>code to use the older function
>
>ie:
>
>$result=3Dpg_exec($database, "update gpinfo set password=3D'$newpw' wher=
e
>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<br>";
>
>Regards
>
>Peter
>
>----- Original Message -----
>From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>To: <pgsql-php [at] postgresql.org>
>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<BR>";
> > 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<BR>";
> >
> > }
> > }
> >
> >
> > 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" <pbay6343 [at] bigpond.net.au>
> > >To: "Yasmine Kedoo" <yazkedoo [at] hotmail.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) !=3D 1) {
> > > ...
> > >
> > >Regards
> > >
> > >Peter
> > >
> > >----- Original Message -----
> > >From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
> > >To: <pgsql-php [at] postgresql.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 err=
or
>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<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.com>
> > > > >To: Yasmine Kedoo <yazkedoo [at] hotmail.com>, pgsql-php [at] 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 [at] 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 [at] postgresql.org so th=
at
>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 [at] 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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.118" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>View a test page with only this function=

within:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><?php</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>    phpinfo();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>?></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Cheers</FONT></DIV>
<BLOCKQUOTE
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LE=
FT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>Fro=
m:</B>
<A title=3Dyazkedoo [at] hotmail.com href=3D"mailto:yazkedoo [at] hotmail.com">Yasm=
ine
Kedoo</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Dpgsql-php [at] postgresq=
l.org
href=3D"mailto:pgsql-php [at] postgresql.org">pgsql-php [at] postgresq l.org</A> </D=
IV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, April 20, 2004 11:2=
0
AM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: [PHP] UPDATE - Changi=
ng
Password</DIV>
<DIV><BR></DIV>Hey.<BR><BR>I'd like to thank everyone who helped me. I wa=
s
able to fix the code by <BR>printing the query to c wat was wrong, and al=
so,
pg_cmdtuples( ) was very <BR>useful :-).<BR><BR>Does anybody know how to =
find
out what version of PHP i may be running?<BR><BR>Thanx
Again<BR><BR>Yasmine<BR><BR><BR><BR>>From: "Peter Bayley" <<A
href=3D"mailto:pbay6343 [at] bigpond.net.au">pbay6343 [at] bigpond.net .au</A>><B=
R>>To:
"Yasmine Kedoo" <<A
href=3D"mailto:yazkedoo [at] hotmail.com">yazkedoo [at] hotmail.com</A>><BR>>=
Subject:
Re: [PHP] UPDATE - Changing Password<BR>>Date: Tue, 20 Apr 2004 13:27:=
01
+1000<BR>><BR>>Hi Yasmine<BR>><BR>>As someone else has alread=
y
noted, you must be running an early version of <BR>>PHP which doesn't =
have
the pg_affected_rows function.<BR>><BR>>The older equivalent functi=
on is
pg_cmdtuples() so you should change your <BR>>code to use the older
function<BR>><BR>>ie:<BR>><BR>>$result=3Dpg_exec($database, "=
update
gpinfo set password=3D'$newpw' where <BR>>gpid=3D'$gpidno'");<BR>>i=
f
(!$result) {<BR>>   print "There was a problem accessing the=

database <BR>>[".pg_errormessage($database)."]\n";<BR>>  =

exit;<BR>>}<BR>>if(pg_cmdtuples($result) !=3D1 ) {<BR>> &nb=
sp;
print "Update Failed: (".pg_cmdtuples($result)." rows were
affected)\n";<BR>>   exit;<BR>>}<BR>>print "Update
Successful\n<br>";<BR>><BR>>Regards<BR>><BR>>Peter<BR>&=
gt;<BR>>-----
Original Message -----<BR>>From: "Yasmine Kedoo" <<A
href=3D"mailto:yazkedoo [at] hotmail.com">yazkedoo [at] hotmail.com</A>><BR>>=
To:
<<A
href=3D"mailto:pgsql-php [at] postgresql.org">pgsql-php [at] postgresq l.org</A>>=
<BR>>Sent:
Sunday, April 18, 2004 7:23 PM<BR>>Subject: Re: [PHP] UPDATE - Changin=
g
Password<BR>><BR>><BR>> > Hi.<BR>> ><BR>> > I hav=
e
changed the code as suggested, but still no luck, and a new
<BR>>error.<BR>> > The error is:<BR>> ><BR>> > Fatal=

error: Call to undefined function: pg_affected_rows() in<BR>> >
/home/webpages/yamkedoo/Tests/chpw1.php on line 55<BR>> ><BR>> &=
gt; I
used the following code:<BR>> ><BR>> > if(!$database)<BR>>=

>      {<BR>>
>         echo "Connection
Failed<BR>";<BR>> > exit;<BR>>
>      }<BR>> ><BR>> > else<BR>&g=
t;
> {<BR>> > $gdidno =3D addslashes(trim($formgpid));<BR>> >=
$newpw
=3D addslashes(trim($formnewpw));<BR>> > $newpw1 =3D
addslashes(trim($formnewpw1));<BR>> ><BR>> > $query =3D "UPDA=
TE
gpinfo SET password=3D'$newpw' WHERE gpid=3D'$gpidno'";<BR>> > $res=
ult =3D
pg_exec($database, $query);<BR>> ><BR>> > if(!$result)<BR>>=
;
> {<BR>> > print "There was a problem accessing the
database";<BR>> > exit;<BR>> > }<BR>> > else
if(pg_affected_rows($result)!=3D1)<BR>> > {<BR>> > print "Upd=
ate
Failed\n";<BR>> > exit;<BR>> > }<BR>> > else
if($result)<BR>> > {<BR>> ><BR>> > print "Update
Successful\n<BR>";<BR>> ><BR>> > }<BR>> > }<BR>&g=
t;
><BR>> ><BR>> > I tried removing this section of the
code:  else<BR>> > if(pg_affected_rows($result)!=3D1)<BR>>=

>           &nb=
sp;            =
  
{<BR>>
>            pr=
int
"Update Failed\n";<BR>>
>           
exit;<BR>>
>           &nb=
sp;            =
   
}<BR>> ><BR>> > as this is where the error is, then got "Upda=
te
Successful", but the<BR>> > password had not been updated.<BR>>=

><BR>> > Any ideas?<BR>> ><BR>> > Yasmine<BR>>
><BR>> ><BR>> ><BR>> ><BR>> ><BR>> ><BR>=
>
><BR>> > >From: "Peter Bayley" <<A
href=3D"mailto:pbay6343 [at] bigpond.net.au">pbay6343 [at] bigpond.net .au</A>><B=
R>>
> >To: "Yasmine Kedoo" <<A
href=3D"mailto:yazkedoo [at] hotmail.com">yazkedoo [at] hotmail.com</A>><BR>>=
>
>Subject: Re: [PHP] UPDATE - Changing Password<BR>> > >Date: =
Sun,
18 Apr 2004 17:28:18 +1000<BR>> > ><BR>> > >Hi
Yasmine,<BR>> > ><BR>> > >An update will not return row=
s
from the query so pg_num_rows will be 0.<BR>> > >You<BR>> >=
;
>should use pg_affected_rows as in..<BR>> > ><BR>> >
>     if (pg_affected_rows($result) !=3D 1) {<BR>&=
gt;
> >         ...<BR>> >=
;
><BR>> > >Regards<BR>> > ><BR>> > >Peter<BR=
>>
> ><BR>> > >----- Original Message -----<BR>> > >=
From:
"Yasmine Kedoo" <<A
href=3D"mailto:yazkedoo [at] hotmail.com">yazkedoo [at] hotmail.com</A>><BR>>=
>
>To: <<A
href=3D"mailto:pgsql-php [at] postgresql.org">pgsql-php [at] postgresq l.org</A>>=
<BR>>
> >Sent: Sunday, April 18, 2004 8:18 AM<BR>> > >Subject: R=
e:
[PHP] UPDATE - Changing Password<BR>> > ><BR>> > ><BR>&=
gt;
> > > Hi.<BR>> > > ><BR>> > > > I think =
i've
sorted the previous problem now, it was a stupid error <BR>>on<BR>>=
>
>my<BR>> > > > part. But the update is still not
working.<BR>> > > ><BR>> > > > I'm using the foll=
owing
script:<BR>> > > ><BR>> > > > else<BR>> > &=
gt;
> {<BR>> > > > $gdidno =3D addslashes(trim($formgpid));<BR=
>>
> > > $newpw =3D addslashes(trim($formnewpw));<BR>> > >=
>
/*$newpw1 =3D addslashes(trim($formnewpw1));*/<BR>> > > ><BR>=
>
> > > $query =3D "UPDATE gpinfo SET password=3D'$newpw' WHERE
gpid=3D'$gpidno'";<BR>> > > > $result =3D pg_exec($database,=

$query);<BR>> > > ><BR>> > > ><BR>> > > =
>
if(!$result)<BR>> > > > {<BR>> > > > print "There=
was
a problem accessing the database";<BR>> > > > exit;<BR>> &=
gt;
> > }<BR>> > > > else if(pg_numrows($result)!=3D1)<BR>&=
gt;
> > > {<BR>> > > > print "Update Failed\n";<BR>> =
>
> > exit;<BR>> > > > }<BR>> > > > else<BR>&=
gt;
> > > {<BR>> > > ><BR>> > > > print "Upd=
ate
Successful\n<BR>";<BR>> > > ><BR>> > > >
}<BR>> > > > }<BR>> > > ><BR>> > > > =
It is
just printing Update Failed now. Can u see where i'm going
<BR>>wrong?<BR>> > > ><BR>> > > > Visit the
following link: <BR>>www.cyber.brad.ac.uk/~yamkedoo/Tests/chpw.html<BR=
>>
> > ><BR>> > > > Username: jjsanderson<BR>> > =
>
> Password: sanderso<BR>> > > ><BR>> > > > The=
n on
the next page, GP ID: GP000001<BR>> > >
>           &nb=
sp;            =
           
New Password: hello<BR>> > > ><BR>> > > > and ign=
ore
retype password for now. As u can see, it is printing <BR>>update<BR>&=
gt;
> > > failed. Can u see the prob?<BR>> > > ><BR>>=
>
> > Cheers<BR>> > > ><BR>> > > > >From: =
Robby
Russell <<A
href=3D"mailto:rrussell [at] commandprompt.com">rrussell [at] commandp rompt.com</A>=
><BR>>
> > > >To: Yasmine Kedoo <<A
href=3D"mailto:yazkedoo [at] hotmail.com">yazkedoo [at] hotmail.com</A>>, <A
href=3D"mailto:pgsql-php [at] postgresql.org">pgsql-php [at] postgresq l.org</A><BR>=
>
> > > >Subject: Re: [PHP] UPDATE - Changing Password<BR>> =
>
> > >Date: Sat, 17 Apr 2004 14:57:43 -0700<BR>> > > >=
;
><BR>> > > > >Yasmine Kedoo typed this on 04/17/2004 02=
:48
PM:<BR>> > > > >>Hi Robby.<BR>> > > >
>><BR>> > > > >>That was recommended to me by som=
eone
else :)<BR>> > > > >><BR>> > > > >>Wh=
en i
remove the trim, i still get the same problem.<BR>> > > >
>><BR>> > > > >>Any other ideas?<BR>> > >=
;
> >><BR>> > > > ><BR>> > > > >Are =
you
getting the same exact error at the same exact character in<BR>> >=

>your<BR>> > > > >query? Send me your error and I'll he=
lp
you more.<BR>> > > > ><BR>> > > > >Robby<BR=
>>
> > > ><BR>> > > > >--<BR>> > > >=

>Robby Russell,  |  Sr. Administrator / Lead Programmer<BR>&=
gt;
> > > >Command Prompt, Inc.   |  <A
href=3D"http://www.commandprompt.com">http://www.commandprom pt.com</A><BR=
>>
> > > >rrussell [at] commandprompt.com | Telephone: (503)
667.4564<BR>> > > > ><BR>> > > >
>---------------------------(end of<BR>> >
>broadcast)---------------------------<BR>> > > > >TIP =
3: if
posting/reading through Usenet, please send an <BR>>appropriate<BR>>=
;
> > > >      subscribe-nomail comman=
d to
<A href=3D"mailto:majordomo [at] postgresql.org">majordomo [at] postgresql.org</A> =
so that
<BR>>your<BR>> > > > >      me=
ssage
can get through to the mailing list cleanly<BR>> > > ><BR>>=
;
> > >
____________________________________________________________ _____<BR>>=
>
> > Express yourself with cool new emoticons<BR>> >
>http://www.msn.co.uk/specials/myemo<BR>> > > ><BR>> &g=
t;
> ><BR>> > > > ---------------------------(end of
<BR>>broadcast)---------------------------<BR>> > > > TIP =
6:
Have you searched our list archives?<BR>> > > ><BR>> > =
>
>           &nb=
sp;   
<A
href=3D"http://archives.postgresql.org">http://archives.post gresql.org</A=
><BR>>
> > ><BR>> > ><BR>> ><BR>> >
____________________________________________________________ _____<BR>>=
>
It's fast, it's easy and it's free. Get MSN Messenger today!<BR>> >=
<A
href=3D"http://www.msn.co.uk/messenger">http://www.msn.co.uk /messenger</A=
><BR>>
><BR>> ><BR>> > ---------------------------(end of
broadcast)---------------------------<BR>> > TIP 4: Don't 'kill -9'=
the
postmaster<BR>>
><BR><BR> ____________________________________________________________ _=
____<BR>Use
MSN Messenger to send music and pics to your friends <BR><A
href=3D"http://www.msn.co.uk/messenger">http://www.msn.co.uk /messenger</A=
><BR><BR><BR>---------------------------(end
of broadcast)---------------------------<BR>TIP 3: if posting/reading thr=
ough
Usenet, please send an appropriate<BR>     
subscribe-nomail command to <A
href=3D"mailto:majordomo [at] postgresql.org">majordomo [at] postgresq l.org</A> so =
that
your<BR>      message can get through to the mai=
ling
list cleanly</BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_017B_01C426CB.AA45E360--
Viorel Dragomir [ Di, 20 April 2004 10:36 ] [ ID #141736 ]

Re: UPDATE - Changing Password

Hi Yasmine,

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

<html>
<head>
<title>PHP server info</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>

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" <pbay6343 [at] bigpond.net.au>
>> To: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>> 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<br>";
>>
>> Regards
>>
>> Peter
>>
>> ----- Original Message -----
>> From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
>> To: <pgsql-php [at] postgresql.org>
>> 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<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.net.au>
>>>> To: "Yasmine Kedoo" <yazkedoo [at] hotmail.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.com>
>>>> To: <pgsql-php [at] postgresql.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.com>
>>>>>> To: Yasmine Kedoo <yazkedoo [at] hotmail.com>, pgsql-php [at] 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 [at] 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 [at] 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 [at] 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
Adam Witney [ Di, 20 April 2004 10:37 ] [ ID #141737 ]

Re: UPDATE - Changing Password

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

> View a test page with only this function within:
> <?php
> phpinfo();
> ?>
>
> Cheers
> ----- Original Message -----
> From: Yasmine Kedoo
> To: pgsql-php [at] 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" <pbay6343 [at] bigpond.net.au>
> >To: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
> >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<br>";
> >
> >Regards
> >
> >Peter
> >
> >----- Original Message -----
> >From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
> >To: <pgsql-php [at] postgresql.org>
> >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<BR>";
> > > 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<BR>";
> > >
> > > }
> > > }
> > >
> > >
> > > 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" <pbay6343 [at] bigpond.net.au>
> > > >To: "Yasmine Kedoo" <yazkedoo [at] hotmail.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) !=3D 1) {
> > > > ...
> > > >
> > > >Regards
> > > >
> > > >Peter
> > > >
> > > >----- Original Message -----
> > > >From: "Yasmine Kedoo" <yazkedoo [at] hotmail.com>
> > > >To: <pgsql-php [at] postgresql.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 =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<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.com>
> > > > > >To: Yasmine Kedoo <yazkedoo [at] hotmail.com>,
> > > > > >pgsql-php [at] 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 [at] 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 [at] 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 [at] 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
nasir [ Di, 20 April 2004 11:10 ] [ ID #141738 ]
Datenbanken » gmane.comp.db.postgresql.php » UPDATE - Changing Password

Vorheriges Thema: postgres, php and osx(panther)
Nächstes Thema: Uploading and parsing a file into a table