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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:25:34+00:00 2026-06-09T02:25:34+00:00

Possible Duplicate: How to properly escape a string via PHP and mysql I’m trying

  • 0

Possible Duplicate:
How to properly escape a string via PHP and mysql

I’m trying to populate a MySQL database, and to do so I’m parsing a data file and running a INSERT INTO ... query.
the table parsonspredictions_R is structured as:

+-------------+---------+------+-----+---------+----------------+
| Field       | Type    | Null | Key | Default | Extra          |
+-------------+---------+------+-----+---------+----------------+
| id          | int(11) | NO   | PRI | NULL    | auto_increment |
| drug_a      | blob    | NO   |     | NULL    |                |
| drug_b      | blob    | NO   |     | NULL    |                |
| correlation | float   | NO   |     | NULL    |                |
| p_value     | float   | NO   |     | NULL    |                |
+-------------+---------+------+-----+---------+----------------+

However, there are some drug_x values which have ' along, so how could I escape my string in other to ignore or remove those ' from the string?

Example:

INSERT INTO parsonspredictions_R (
    drug_a,
    drug_b,
    correlation,
    p_value
) VALUES(
   '2'-Hydroxyflavanone_28_0',
   'Emodin',
   0.165714,
   0.0019
);

Results in:

Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”, ‘Emodin’, 0.165714, 0.0019 )’ at line 1-b

  • 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-09T02:25:35+00:00Added an answer on June 9, 2026 at 2:25 am

    You can escape ‘-character by typing

    INSERT INTO parsonspredictions_R (
        drug_a,
        drug_b,
        correlation,
        p_value
    ) VALUES(
        '2''-Hydroxyflavanone_28_0',
        'Emodin',
        0.165714,
        0.0019
    );
    

    Or you can put your string in MySQL query in “”-quotes.

    edited:
    To make your file ready for regex you can use mysql_real_escape_string() on text before using regex. It will escape all suspicious characters, like ‘-character.

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

Sidebar

Related Questions

Possible Duplicate: How can I properly escape HTML form input default values in PHP?
Possible Duplicate: Find url from string with php I found this code: but 2
Possible Duplicate: how to delete item from listView? I fetch data from Database in
Possible Duplicate: Python not sorting unicode properly. Strcoll doesn't help. I'm trying to sort
Possible Duplicate: How to run a database script file from Delphi? I have a
Possible Duplicate: Special characters in PHP / MySQL I have a problem. I have
Possible Duplicate: How to properly clean up Excel interop objects in C# I have
Possible Duplicate: Handling InterruptedException in Java I wonder how InterruptedException should be properly handled.
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP

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.