Jump to content

erors!!! ARG!!!


TheFilmGod

Recommended Posts

Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /home/content/i/n/t/internetknight/html/register_new.php on line 72

 

Warning: Wrong parameter count for array_key_exists() in /home/content/i/n/t/internetknight/html/register_new.php on line 172

 

Code for warning 1:

// Set pattern matching for user
		$u_regex = "[A-Za-z0-9_]{6,20}$";

		// If username has between 6 and 20 word characters
		if ( preg_match($u_regex, $user)) {...

 

Code for warning 2:

	if ( array_key_exists($error)) {..

 

What did I do wrong?

 

 

Link to comment
https://forums.phpfreaks.com/topic/67689-erors-arg/
Share on other sites

1.) The syntax of your regular expression is for use with ereg()

Try:

		$u_regex = "^[A-Za-z0-9_]{6,20}$";

		// If username has between 6 and 20 word characters
		if (ereg($u_regex, $user)) {...

 

Notice i modified your expression slightly. You'll need the ^ to make sure the match is for the entire string. With your previous expression, someone could have put any characters at the beginning of the string, so long as the last 6-20 where alphanumeric or underscores.

2.) Again, the manual is your friend: www.php.net/array_key_exists

 

The function requires two parameters, the first being the key you are looking for, the second being the array in which you are searching.

Link to comment
https://forums.phpfreaks.com/topic/67689-erors-arg/#findComment-340047
Share on other sites

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.