Solved

PHP - Function eregi() is deprecated error message.

Posted on 2012-03-13
3
697 Views
Last Modified: 2012-06-27
Hi,
I am receiving the following error message.

Deprecated: Function eregi() is deprecated in /home/mywebsit/public_html/includes/functions.php on line 262

How should I recode the code below to correct the error?


$GP_uploadAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  if (!eregi("GP_upload=true", $HTTP_SERVER_VARS['QUERY_STRING'])) {
            $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING']."&GP_upload=true";
      } else {
            $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
      }
} else {
  $GP_uploadAction .= "?"."GP_upload=true";
}
0
Comment
Question by:sabecs
3 Comments
 
LVL 15

Expert Comment

by:StingRaY
ID: 37713453
$GP_uploadAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  if (preg_match("/GP_upload=true/", $HTTP_SERVER_VARS['QUERY_STRING']) == 0) {
            $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING']."&GP_upload=true";
      } else {
            $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
      }
} else {
  $GP_uploadAction .= "?"."GP_upload=true";
}

Open in new window

0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 37713461
you can use stripos as no wildcard is in your regexp and thus no regular expression needed. Also replace the HTTP- long array as they are gone wiht php 5.4. THis code works without warning on php 5.4

$GP_uploadAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  if (stripos("GP_upload=true", $_SERVER['QUERY_STRING']) === false) {
            $GP_uploadAction .= "?".$_SERVER['QUERY_STRING']."&GP_upload=true";
      } else {
            $GP_uploadAction .= "?".$_SERVER['QUERY_STRING'];
      }
} else {
  $GP_uploadAction .= "?"."GP_upload=true";
}

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37714071
For PHP developers, the PHP.net web site is an invaluable resource.  If you are upgrading to PHP 5.4, you really need to read this:
http://php.net/migration54

On that page you will also find a line with the links for the other recent upgrade paths.  It says something like this:
See also the migration guides for PHP versions 5.0.x, 5.1.x, 5.2.x and 5.3.x.

The migration guides explain what is deprecated and what is removed, as well as what is added in each new release of PHP.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now