Quote:
Originally Posted by HelloWorld isn't this suppose to be a run-time error as well..? |
No. Let me give an example. I once helped someone on a forum who had a problem similar to this:
[paraphrase]
I am trying to allow someone to log in only if their username and password are valid. Here's' my code:
PHP Code:
if (!mysql_query("select * from user where username='".$username."' and password='".$password."'")) {
$_SESSION['user'] = mysql_fetch_assoc();
} else {
//send error message
}
[/paraphrase]
Now, that code
is functional. It does not throw errors at run-time. It
does contain a logical error. They inadvertently included the ! in the conditional expression reversing the order of results. The proper code would be
PHP Code:
if (mysql_query("select * from user where username='".$username."' and password='".$password."'")) {
$_SESSION['user'] = mysql_fetch_assoc();
} else {
//send error message
}
[/paraphrase]
"Proper" being defined as following the logic dictated by the system owner.