muffin100 Posted April 5, 2006 Share Posted April 5, 2006 I'm trying to write a register page and this parse error came out:Parse error: syntax error, unexpected '[' in /usr/local/apache2/htdocs/register.phpHere is part of the code:if (eregi ('^[[:alpha:]]\.\'\-{2,15}$',stripslashes(trim($POST['name'])))) {$n = escape_data($_POST['name']);} else {$n = FALSE ;echo '<p><font color="red" size="+1">Please enter a user name!</font></p>';}I thought it is the single quotes problem so I have tried this:if (eregi ('^[[:alpha:]]{2,15}$',stripslashes(trim($POST['name'])))) {$n = escape_data($_POST['name']);} else {$n = FALSE ;echo '<p><font color="red" size="+1">Please enter a user name!</font></p>';}but the same error popped up, can anyone tell me what the problem is? Link to comment https://forums.phpfreaks.com/topic/6693-parse-error-need-help/ Share on other sites More sharing options...
heckenschutze Posted April 6, 2006 Share Posted April 6, 2006 Im not sure if this is your error, but it could be it...You forgot an underscore: [code]$POST['name'][/code]meaning the line should be:[code]if(eregi('^[[:alpha:]]\.\'\-{2,15}$', stripslashes(trim($_POST['name'])))){ // ...[/code]hth. Link to comment https://forums.phpfreaks.com/topic/6693-parse-error-need-help/#findComment-24383 Share on other sites More sharing options...
vombomin Posted April 6, 2006 Share Posted April 6, 2006 try this maybeif (eregi ('^[ :alpha: ]{2,15}$',stripslashes(trim($POST[ 'name' ]))) {$n = escape_data($_POST['name']);} else {$n = FALSE ;echo '<p><font color="red" size="+1">Please enter a user name!</font></p>';} Link to comment https://forums.phpfreaks.com/topic/6693-parse-error-need-help/#findComment-24407 Share on other sites More sharing options...
muffin100 Posted April 11, 2006 Author Share Posted April 11, 2006 Tried both ways and the parse error still came out.Thanks though. Link to comment https://forums.phpfreaks.com/topic/6693-parse-error-need-help/#findComment-25734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.