11

Anyone knows how to solve the error below?

Deprecated: Function ereg() is deprecated in C:\wamp\www\includes\file.inc on line 895

It is happening after installing Drupal 6.13 on wamp server 2.0i with PHP 5.3.0

the
  • 21,007
  • 11
  • 68
  • 101
João Guilherme
  • 1,371
  • 1
  • 15
  • 27

8 Answers8

47

Use

preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

Instead of

ereg('\.([^\.]*$)', $this->file_src_name, $extension);
the
  • 21,007
  • 11
  • 68
  • 101
Parmendra Singh
  • 1,015
  • 3
  • 15
  • 27
11

Drop your error reporting level below E_DEPRECATED.

PHP 5.3 introduced two new error reporting levels, E_DEPRECATED and E_USER_DEPRECATED and - for the first time in PHP's history - they've started to walk away from older parts of their API. The ereg_* function will still work, but this warning is intended to let you know that "hey, these function will be going away soon, probably in the next major revision).

Augusto
  • 2,125
  • 18
  • 27
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
2

Just add @ in front of the function. e.g.

@ereg()

more issue relating upgraded your web servers which running PHP 5.3.0, pls refer

http://www.rain-forest-forum.com/dotproject-net-installation-issues-t263.html

ex_plo_rer
  • 61
  • 1
  • 1
  • 1
    E_DEPRECATED means that the feature will be removed at some point (indeed, since this comment it has been!), so you are just kicking the problem down the line here. Better practice for E_DEPRECATED would be to replace the line of code with something else. In this case preg_match would be the one. – Mikey C Nov 02 '18 at 14:36
  • This does not solve the use of the depreciated function, it only hides the error message! See @ParmendraSingh's answer for a replacement (working) method. – TPHughes Jan 23 '19 at 12:53
2

This is not a Drupal issue.In the Drupal site it is noted that it does not yet support PHP 5.3 and there have been new error flags added to PHP.

Solution1 : You can degarde the PHP version.You can revert back to PHP 5.2.x. As I am unsure of other conflicts with Drupal and PHP 5.3.

Solution2 : However, if you prefer to keep PHP 5.3, you can always suppress the deprecated function errors. In Drupal’s includes/common.inc, Find the line :

if ($errno & (E_ALL ^ E_NOTICE)) { And replace it with:

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

This will now always suppress the Deprecated error messages.

Ipsita Rout
  • 4,945
  • 4
  • 36
  • 40
1

One solution is to upgrade the offending sourcecode :-) It's explained here: http://drupal.org/node/514334#comment-2852940

Simon B.
  • 2,530
  • 24
  • 30
0

You can edit you common.inc file to quietly disregard the deprecated error flags. See my post: http://funkinetics.org/klink/function-ereg-is-deprecated-error-in-drupal-6x-with-php-53/

  • RayRay I think Alan Storm's suggestion is better because you just change the PHP error reporting level. Either way thanks for your answer ! – João Guilherme Jul 21 '09 at 13:09
-2

Looks like the problem is with PHP 5.3.0. You could try downgrading to 5.2.9 as suggested by this drupal link: http://drupal.org/node/514334

quickcel
  • 506
  • 2
  • 8
  • 15
  • So instead of correcting the error, you would suggest downgrading to a massively inferior version of PHP.... smh. – Hobbes May 24 '17 at 21:13
-2

Because I don't have time to update legacy code, I addeded following line to php code to suppress warnings.

error_reporting(E_ALL ^ E_DEPRECATED);

this line suppress only deprecated warnings. other errors are shown as usual.

trante
  • 33,518
  • 47
  • 192
  • 272