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 80383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:17:39+00:00 2026-05-10T21:17:39+00:00

I run all my integers through a (int)Integer to make them safe to use

  • 0

I run all my integers through a (int)Integer to make them safe to use in my query strings.

I also run my strings through this function code:-

if(!get_magic_quotes_gpc()) {            $string = mysql_real_escape_string($string);         }  $pattern = array('\\'', '\\\'', '\\\\', '\\0'); $replace = array('', '', '', ''); if(preg_match('/[\\\\'\'\\0]/', str_replace($pattern, $replace, $string))) $string = addslashes($string);    $cleanedString = str_replace('%','',$string); 

I obviously return the $cleanedString variable. Now I replace the % character because it is a wildcard to mySQL and it could potentially slow down my queries (or make them return incorrect data) if the user inserted them. Are there any other special characters for mySQL I should be concerned about?

On a second note, is there anything wrong or redundant about my search and replace after the mysql_real_escape_string? I got it from a website when I was first starting out and (if I remember correctly) it said you had to use this search/replace in addition to the escape string. It looks like it’s trying to remove any previously escaped injection characters?

  • 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. 2026-05-10T21:17:39+00:00Added an answer on May 10, 2026 at 9:17 pm

    yeah I think you’ve got things going a bit strangely there.

    First of all, I’d check for magic quotes and remove the slashes if it’s turned on. That way you’ve got a string which actually represents the information you want (and not one that has been treated with slashes).

    If you particularly want to remove the % wildcard then you could just escape that or remove it altogether. Before you insert the string into an SQL query, finally run it through mysql_real_escape_string, and everything will be fine.

    $string = $_POST['searchTerm']; if (get_magic_quotes_gpc()) {     $string = stripslashes($string); } $string = str_replace('%', '', $string); $safeString = mysql_real_escape_string($string); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say, if I have foo.exe bar.exe baz.exe How do I run all of them
I want this for some conditional compilation code that will run in all IE's
All web developers run into this problem when the amount of data in their
// The worst possible legal hash function - never use! @Override public int hashCode()
From Eclipse I can easily run all the JUnit tests in my application. I
Once I run search all using Ctrl + Shift + F then my search
Is it true that in the flash/air player the actionscripts are all run in
When I run cake bake all then I receive the error messages shown below.
I would like to run JSHint on all my Javascript source files but several
My original understanding was that the asp.net page lifecycle is run once for all

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.