Now, $num here is just the number of lines of data from a database search. Sometimes, it will be 0. $procrastinate is a function argument.
if ($num==0) {
return "Do not appear to be registered. Please check your email input again.";
break 1;
} else { // there is an entry. check for consistency
$procrastinateDB = mysql_result($result,0,'procrastinate');
if ($procrastinate != $procrastinateDB) {
return "Answer to your procrastination question is incorrect. Please try again!";
break 2;
}
else {
$username = mysql_result($result,0,'usrname');
$passwd = mysql_result($result,0,'passwd');
return array($username, $passwd, $num);
break 2;
}
}
What I'm not understanding is that even when $num=0, an array is still returned with $usersname = 'D', $passwd = 'o', and $num = ' '. Clearly, it's taking the first returned statement and just assigning these variables to each character in the first returned sentence in sequential order.
How do I stop this? I don't want $username, $passwd, $num to contain any value if there is no database entry.
break
statements are useless here.return
already exits the function, sobreak
is not needed. – Rocket Hazmat Nov 18 '11 at 17:17