Jump to content

Cant figure out this error


skoobi

Recommended Posts

Hi im still learning php and have been running through the tutorials on making a user authentication system but im getting an error on one line but ive got the same code else where and its fine...

 

// Must have at least one character
if (strspn($_POST['user_name'],$span_str) == 0) {
	return false;
}

Im getting the error on the if statment but no matter what i try it still tells me theres an error...

 

Heres the full function code:

function account_namevalid() {
// parameter for use with strspan
$span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";

// Must have at least one character
if (strspn($_POST['user_name'],$span_str) == 0) {
	return false;
}

// Must contain all legal characters
if (strspn($_POST['user_name'],$span_str) != srnlen($name)) {
	return false;
}

// Min and Max length
if ($strlen($_POST['user_name']) < 5) {
	return false;
}
if strlen($_POST['user_name']) > 25 {
	return false;
}
// Illegal names
if 
(eregi("^((root)|(bin)|(deamon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)|(uucp)|(operator)|(games)|(mysql)|
		  (httpd)|(nobody)|(dummy)|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download)))$", $_POST['user_name'])) {
			  return false;
		  }
		  if (eregi("^(anoncvs_)", $_POST['user_name'])) {
			  return false;
		  }
return true;
}

 

Any help or info would be greatfull...

Cheers

Chris

Link to comment
https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/
Share on other sites

I can see two errors:

// Must contain all legal characters
if (strspn($_POST['user_name'],$span_str) != srnlen($name)) {
	return false;
}

spelling mistake,

should be:

// Must contain all legal characters

if (strspn($_POST['user_name'],$span_str) != strlen($name)) {

return false;

}

and

if strlen($_POST['user_name']) > 25 {
	return false;
}

missing brackets:

if (strlen($_POST['user_name']) > 25) {
	return false;
}

 

Ah missed that one... Well after the spelling corrections and missing bracket Im getting another error which i cant work out.

'Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in path_to_dir/register_funcs.php on line 85'

 

Line 85 is this again...

	// Must have at least one character
if (strspn($_POST['user_name'],$span_str) == 0) {
	return false;
}

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.