0

I changed a php project from XAMP to WAMP. when i try to test the forms in project i get an error.

The error is like this

Deprecated: Function ereg() is deprecated in C:\wamp\www\widephp\includes\functions\general_functions.php on line 135

and the 135th line is

if(!ereg("^[a-z0-9_.]+@[a-z0-9]+\.([a-z.]{2,15})",trim($v))) {

the full part the line contains given below

foreach($fieldEmail as $v) {
    if(!ereg("^[a-z0-9_.]+@[a-z0-9]+\.([a-z.]{2,15})",trim($v))) {
        $alert = "Enter a valid Email address";
        return false;
    }
}

Can anyone help with this?

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
user1514316
  • 11
  • 1
  • 7

2 Answers2

0

As the message indicates, the function ereg() is deprecated.

Your platform change most likely included either an upgrade in the php version, or changes in th error output, or maybe both.

From the manual:

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

My advice: Follow the manuals advice. Use preg_match() instead. Keep in mind you have to adjust the syntax of your regex, here is the documentation of it in the php manual.

Bjoern
  • 15,934
  • 4
  • 43
  • 48
  • i changed as u said bt nw email field is not validating am getting "Enter a valid Email address" this error – user1514316 Sep 11 '12 at 08:54
  • As I've pointed out, you have to adjust the syntax of your regex. If you just want to validate an email, there are better solutions out there if you want to do it properly. Just have a look at this SO post for example: http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address – Bjoern Sep 11 '12 at 08:57
0

You can downgrade your PHP version (which is not appreciated) or follow the @Bjoern's answer. To downgrade PHP version on wamp:

WAMP > PHP> Version > Get more

download version under 5.3, install it and than change version:

WAMP > PHP> Version > 5.2.X

my edit was declined by @Bjoern, so i write this as an answer.

loler
  • 2,594
  • 1
  • 20
  • 30