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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:37:09+00:00 2026-06-03T22:37:09+00:00

I get this error when I execute this statement in PHP: $sql = mysql_real_escape_string(INSERT

  • 0

I get this error when I execute this statement in PHP:

    $sql = mysql_real_escape_string("INSERT INTO `locations`(`id`,`anchor_url`,`anchor_title`) 
    VALUES (1,`http%3A%2F%2Fmaps.google.com%2Fmaps%2Fms%3Fmsid%3D210426849026628615459.0004bd6aaf4e431aab7f9%26msa%3D0%26output%3Dembed`, `Se "Mar Menor" på kartet`)");

I figure it has something to do with the quotes, but I’ve tried different quotes, which has provided me with another error saying I have an error in the SQL syntax (single quote).

The error that is thrown when the above query is executed is:

Unknown column ‘http%3A%2F%2Fmaps.google.com%2Fmaps%2Fms%3Fmsid%3D210426849026628615459.0004bd6aaf4e431aab7f9%26msa%3D0%26output%3Dembed’ in ‘field list’

EDIT:

Answer was accepted but only for some of it as I did not test the other info provided: I used PDO to query the database instead with prepared statements.

  • 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-03T22:37:11+00:00Added an answer on June 3, 2026 at 10:37 pm

    You cannot call mysql_real_escape_string on the whole query; you must call it on each one variable separately.

    Example:

    // THIS IS AN EXAMPLE ONLY -- NOT A BEST PRACTICE!
    $sql = "INSERT INTO `locations`(`id`,`anchor_url`,`anchor_title`) VALUES ".
           "(1, '".mysql_real_escape_string('http://...')."', ".
           "'".mysql_real_escape_string('whatever')."')";
    

    You also have to pay attention to the single quotes around the values that mres produces; these are absolutely critical.

    Now of course the above looks extremely ugly, so you can pretty it up a little:

    // THIS IS AN EXAMPLE ONLY -- NOT A BEST PRACTICE!
    $sql = sprintf("INSERT INTO `locations`(`id`,`anchor_url`,`anchor_title`) VALUES ".
                   "(1, '%s', '%s')",
                   mysql_real_escape_string('http://...'),
                   mysql_real_escape_string('whatever'));
    

    The above is pretty much the bare minimum that you have to do to sanitize input to the database. But it would be much better if you used prepared statements instead (either with the mysqli or the PDO extensions).

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

Sidebar

Related Questions

I get this error:- You have an error in your SQL syntax; check the
i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I get this error message when installing SQL 2005 Analysis services. The cabinet File
I get this error when I try to call $func('something') : if(($object instanceof MyObject)
I get this error when I try recreate tables in my database with hibernate.
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
We get this error in Visual Studio 2005 and TFS very often. Can anyone
I get this error: System.Reflection.TargetException: Object does not match target type. when trying to

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.