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
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;
}

 

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.