We're upgrading from php 5.3 to 5.4, which is not backwards compatible for 'get_magic_quotes_gpc'. I understand the code will still work, sort of, but just bring back a FALSE each time.
However, I think the time has come to scrub this from our code.
Here's a typical example:
     $product_id = "0";
        if (isset($HTTP_GET_VARS["id"])) {
          $rid = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS["id"] : addslashes($HTTP_GET_VARS["id"]);
        }
       //then $product_id gets used all over the place in many different queries
I've been researching how to fix this and this is what I came up with:
    $rid = "0";
    if (isset($HTTP_GET_VARS["id"])) {
    $rid = addslashes($HTTP_GET_VARS["id"]);
    }
I'm a little over my head here. I know this all has to do with SQL injection and such. Is my solution an reasonable/acceptable one?
Thanks in advance.
<<<< EDIT - ADDITIONAL INFORMATION >>>>
Thanks for the replies. Actually, we did a bunch of conversion to PDO about 18 mos ago (mostly due to this type of advice on stackoverflow :)
So, I may have some reduntant, pointless code going on. Here's the full picture of what is happening below the code I posted above that gets the variable from the URL.
You'll see, there is the (get_magic_quuotes_gpc) that used to be there, now commented out and replaced by the (addslashes). But that variable is passed on to a PDO query.
$product_id = "0";
if (isset($HTTP_GET_VARS["id"])) {
  //$product_id = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS["id"] : addslashes($HTTP_GET_VARS["id"]);
  $product_id = addslashes($HTTP_GET_VARS["id"]);
}
// NEW QUERIES - BEG xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
try {  
    # MySQL with PDO_MYSQL  
    $pdo = new PDO("mysql:host=$hostname_db;dbname=$database_db", $username_db, $password_db);  
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    // Query 1:  product details
    $stmt = $pdo->prepare('SELECT 
    [a bunch of stuff here, fields, joins, etc]
    WHERE product_id = ? ');  
    $stmt -> execute(array($rid));
    $row_count_resto_details = $stmt->rowCount();
    $row_resto_details = $stmt->fetch(PDO::FETCH_ASSOC);
}  
// Error message for pdo
catch(PDOException $e) {  
    echo $e->getMessage();  
}  
// END QUERY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Can I just get rid of all the stuff in the first 4-5 lines of code and just make it this:
$product_id = $HTTP_GET_VARS["id"];
 
     
    