Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8072825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:09:08+00:00 2026-06-05T14:09:08+00:00

In a login script I found onlline, the creator added this function to prevent

  • 0

In a login script I found onlline, the creator added this function to prevent SQL-injection attacks.

function Fix($str) {
    $str = trim($str);
    if(get_magic_quotes_gpc()) {
        $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
}

Since I read that magic_quotes_gpc is (or has been) removed, it feels like this function is a bit outdated. Wouldn’t just simply using mysqli_real_escape_string($user_input) add sufficient security?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:09:09+00:00Added an answer on June 5, 2026 at 2:09 pm

    mysql_real_escape_string is not sufficient in all situations but it is definitely very good friend. The better solution is using Prepared Statements

    //example from http://php.net/manual/en/pdo.prepared-statements.php
    
    $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
    $stmt->bindParam(1, $name);
    $stmt->bindParam(2, $value);
    
    // insert one row
    $name = 'one';
    $value = 1;
    $stmt->execute();
    

    Also, not to forget HTMLPurifier that can be used to discard any invalid/suspicious characters.

    mysql_real_escape_string() versus Prepared Statements

    mysql_real_escape_string() prone to
    the same kind of issues affecting
    addslashes().

    Answer From Chris Shiflett (Security Expert)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this login script and I'm trying to implement it into my website
Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)
Hey This is my login script, using PHP5 and MYSQLi, I just had help
What is wrong with this login script? I have a modal-style iframe login box
I was looking around for more correct login/logout portions of code, and found this
i have used the login script which is found here http://www.phpeasystep.com/phptu/6.html the script works
I have a login script that I found on some page a while ago,
I scanned my login script using SQL Inject Me Firefox addon According to the
I'm creating a login script. In this script, I would like to limit the
I have the following call in my RoR script: Foo.where(event = 'Login').group('user_id').order('user_id ASC').count() This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.