View Single Post
  #3 (permalink)  
Old 11-30-2007, 08:33 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 428
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
Quote:
Originally Posted by HelloWorld View Post
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.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to TeraTask For This Useful Post:
HelloWorld (11-30-2007)