Jump to content

Tiny syntax explanation


bobicles2

Recommended Posts

I means if the variable $login does not contain any text then to perform a section of code.

 

How would this have any reference to this script though, because if the login field which is defined as $login has no text, then it has nothing to look up in the database and compare against (as the script below is designed to checked for duplicate log in names)

 

if($login != '') {
	$qry = "SELECT * FROM members WHERE login='$login'";
	$result = mysql_query($qry);
	if($result) {
		if(mysql_num_rows($result) > 0) {
			$errmsg_arr[] = 'Login ID already in use';
			$errflag = true;
		}
		@mysql_free_result($result);
	}
	else {
		die("Query failed");
	}

 

I means if the variable $login does not contain any text then to perform a section of code.

 

Actually, it's saying if the variable does not NOT contain any text, then perform the code. It's essentially the same as if( !empty($login) )

I means if the variable $login does not contain any text then to perform a section of code.

 

Actually, it's saying if the variable does not NOT contain any text, then perform the code. It's essentially the same as if( !empty($login) )

 

now it makes perfect sense, so long as the field has an entry, we check the database for multiple entries

 

thanks man!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.