user3304633
user3304633

Reputation: 27

PHP ereg_replace is not working correctly

My id is a5efa5.

Code below replacing deprecated[?] [^a-z0-9] is not working. a5efa5 in an id in my database table.

//Connect to the database through our include 
include_once "database.php";
// Get the member id from the URL variable
$id = $_REQUEST['id'];
$id = ereg_replace("[^a-z0-9]", "", $id); // filter everything but numbers for security
if (!$id) {
    echo "Missing Data to Run";
    exit(); 
}

Help me friends, where did I make a mistake...

Upvotes: -2

Views: 110

Answers (2)

LONGMAN
LONGMAN

Reputation: 990

Use preg_replace

$id = preg_replace('#[^a-z0-9]+#', '', $id);

Upvotes: 1

Pattle
Pattle

Reputation: 6014

It could be because ereg_replace is deprecated. Below is what is stated on the php.net website

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

If you are using a version or PHP greater than 5.3.0 then it will not work.

Upvotes: 1

Related Questions