skoobi Posted October 27, 2011 Share Posted October 27, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/ Share on other sites More sharing options...
Nodral Posted October 27, 2011 Share Posted October 27, 2011 What error are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/#findComment-1282599 Share on other sites More sharing options...
harristweed Posted October 27, 2011 Share Posted October 27, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/#findComment-1282602 Share on other sites More sharing options...
skoobi Posted October 30, 2011 Author Share Posted October 30, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/#findComment-1283413 Share on other sites More sharing options...
harristweed Posted October 30, 2011 Share Posted October 30, 2011 post full code - error might be before this line Quote Link to comment https://forums.phpfreaks.com/topic/249889-cant-figure-out-this-error/#findComment-1283474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.