Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
bytte
- Forum Commoner
- Posts: 75
- Joined: Sun Nov 23, 2003 8:20 am
- Location: Belgium
Post
by bytte »
Is this query correct?
Code: Select all
UPDATE mailinglist SET active = 1, activated_dt = NOW() WHERE active = 0 AND pass = 'ec1f825b' AND ID = '3'
It appears to update the record even if the pass value is not correct.
Any idea?
-
Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Post
by Chris Corbyn »
It sure looks OK to me
Could you maybe send the SQL export? Though what difference it'll make I'm not sure.
-
bytte
- Forum Commoner
- Posts: 75
- Joined: Sun Nov 23, 2003 8:20 am
- Location: Belgium
Post
by bytte »
Oh, excuse me. It doesn't update the record (which is normal, if $act is not correct, but my code still returns TRUE.
This is the exact code:
Code: Select all
function activateAddress($ID,$act) {
$sql = "e;UPDATE
mailinglist
SET
active = 1,
activated_dt = NOW()
WHERE
active = 0 AND
pass = '"e; . $act . "e;' AND
ID = '"e; . $ID . "e;'"e;;
$result = mysql_query($sql);
if (!$result) {
return FALSE;
} else {
return TRUE;
}
}
-
Syranide
- Forum Contributor
- Posts: 281
- Joined: Fri May 20, 2005 3:16 pm
- Location: Sweden
Post
by Syranide »
as the query was valid it returns TRUE;
what you want is mysql_affected_rows.
-
bytte
- Forum Commoner
- Posts: 75
- Joined: Sun Nov 23, 2003 8:20 am
- Location: Belgium
Post
by bytte »
Thanks.