Function ereg, is deprecated——drupal6.13 & PHP5.3

Installing Drupal · Drupal 6.x

vreddymasu - July 9, 2009 - 05:32

Instaling drupal-6.13 ,i configured mysql database and users on that time showing this error.can any one resolve this problem

Function ereg() is deprecated in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal\includes\file.inc on line 895

Similar Problem

StormDruper - July 12, 2009 - 02:10

Hello,

I am a newbie and just installed wampserver 2.0 on Win XP (containing PHP 5.3.0) and then tried to install Drupal 6.13 and got the same error message above ("Deprecated: Function ereg() is deprecated in C:\wamp\www\drupal-6.13\includes\file.inc on line 895"). There seem to be a few other posts about this ... someone recommended simply replacing ereg() with preg_match(), but that leads to another series of messages for me: "preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in C:\wamp\www\drupal-6.13\includes\file.inc on line 895". Has anyone successfully fixed this problem? Thanks for any help.

workaround?

faux_codex - July 12, 2009 - 06:24

i'm a noob with this too, so i can't vouch that it won't break anything else but here's what worked for me (granted, i've only made the install work a few minutes ago and haven't tried to configure anything, but the error msg is gone now)

from the wamp tray icon>PHP>Version>Get more...

that should take you to the WAMP site and give you a list of of the PHP versions you can download

(i figured the depreciation came in v5.3.0) so i just downloaded the PHP 5.2.9-2 installer...

shut down WAMP

install 5.2.9-2 exe

restart WAMP

wamp tray icon>PHP>Version and then tagged 5.2.9-2

wamp tray icon>Restart All Services

again, i'm too much a noob to know if that's "proper" for now (and although i saw a similar "fix" post about replacing with the preg... i still was doing something wrong)

good luck, i'll post a followup if it appears that doesn't work (just going through a tutorial right now)

f_c

Thanks

rpmckee - August 13, 2009 - 02:23

I degraded the php server and I got rid of the errors. I thought the problem had to do with Windows 7. Thanks again.

Login or register to post comments

I agree ...

StormDruper - July 12, 2009 - 21:36

I am in agreement with faux_codex's post above. I had the problems above ("Deprecated: Function ereg() is deprecated in C:\wamp\www\drupal-6.13\includes\file.inc on line 895") when I installed wampServer 2.0i (containing PHP 5.3.0) but have no such problem when I install wampServer2.0h (containing PHP 5.2.9-2). This isn't necessarily a "fix", as it appears that Drupal 6.13 still calls a function which is deprecated in PHP 5.3.0. So, for the time being, if you use a PHP version before 5.3.0, the problem should go away.

Fix for Deprecated Errors

RayRay - July 20, 2009 - 18:55

If you prefer to keep PHP 5.3, you can always suppress the errors. In Drupal's includes/common.inc, find line 590. It should be listed as:

    if ($errno & (E_ALL ^ E_NOTICE)) {

Replace this line with:

    if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {

This will now always suppress the Deprecated error messages. If you have the developer tools module, you'll need to make the same change to devel/devel.module line 460.

Note that every time you update Drupal or the Devel module you'll have to manually make this change until they finally patch them to deal properly with php 5.3.

Make a change in php.ini

webghost - July 26, 2009 - 15:55

error_reporting =E_ALL & ~E_DEPRECATED

All will work

Won't work for everyone...

RayRay - August 6, 2009 - 21:53

Many people have hosted accounts where they don't have the option to edit their php.ini. Also, editing php.ini will turn off the deprecated warnings for ALL php code not just Drupal. If your turning them off on your local machine while developing, as soon as you migrate your code to a hosted system the errors will appear again in an environment where you can't mess with PHP's configuration.

In general it's good to get these warnings but suppress them at the application layer--you want these errors when your writing your own code so you can avoid using those function. Come the next round of PHP, the deprecated functions are going bye-bye and if you don't heed the warnings you (or whoever inherits your code) will be stuck.

Drupal will probably resolve them in a few months, but until then I highly recommend patching the broke application and leaving PHP alone.

I used this in my .htaccess

AdrianB - August 11, 2009 - 21:35

I used this in my .htaccess file:

php_value error_reporting 4096

That solved the deprecated warning for my setup (XAMPP on Mac).

Solved- For now....

mr.perseids - August 24, 2009 - 16:48

Hi all,

Function ereg() is deprecated in drupal-6.13\includes\file.inc on line 895

open the file.inc in a good text editor other than notepad, go to the line number 895 to see the following line. Then comment the line and in the next line type the replaced code. this will solve the instalation issues and also most of other issues related to the same issue.

Change

elseif ($depth >= $min_depth && ereg($mask, $file)) {

to

elseif ($depth >= $min_depth && mb_ereg($mask, $file)) {

mb_ereg fortunatly is not deprecated

i think its more safe to to

chintu84 - August 30, 2009 - 02:41

that seems to work.. i wonder if preg_match would work as well??

elseif ($depth >= $min_depth && preg_match($mask, $file)) {

That's it . . . . That worked! . . . . that's the ticket . . . .

t4him - August 25, 2009 - 14:30

I just installed wamp (removed xampp) and got this error on my first drupal 6x install. I changed the files.inc file and it works fine. Thanks!