Page 1 of 1

mysql affected rows

Posted: Sat Jun 12, 2004 11:58 pm
by ol4pr0
the following will always say the that the account has been activated.

Code: Select all

# sorry my mistake UPDATE table should be UPDATE users  


$query = mysql_query("UPDATE table SET unique_id='$_GET[id]',active=1 WHERE unique_id='$_GET[id]' AND active=0");
if(mysql_affected_rows()==1) {
//  if (mysql_affected_rows($query)==1) {
print 'you are activated';
}
else
{
print 'you are already activated or you have not been sent activation';    
}
I must be doing something wrong here

Posted: Sun Jun 13, 2004 2:17 pm
by scorphus
Try this;

Code: Select all

<?php
mysql_connect($srv, $usr, $pwd) or die("Could not connect: " . mysql_error());
mysql_select_db($db);
$query = "UPDATE table SET unique_id='" . $_GET['id'] . "',active=1 WHERE unique_id='" . $_GET['id'] . "' AND active=0";
$result = mysql_query($query) or die("Could not query: " . mysql_error());
if (mysql_affected_rows($result) == 1)
	print 'you are activated';
else
	print 'you are already activated or you have not been sent activation';   
?>
-- Scorphus.