Jump to content

Archived

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

muffin100

Parse Error Need help

Recommended Posts

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.php

Here 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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
try this maybe

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

Share this post


Link to post
Share on other sites

×

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.