Solved

I want to prepare a string for mysql insert by handling a single quote

Posted on 2012-03-29
4
342 Views
Last Modified: 2012-03-29
I have string with single quotes that I need to handle before inserting into mysql.

Quote examples are      hel'lo    or   hello'    or  'hello


How can I use a perl regex to add another single quote in front of the single quote within the string?

hel''lo
0
Comment
Question by:dmalovich
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37783627
Two single quotes doesn't provide an escape sequence in MySQL.  It does work in Microsoft SQL Server / T-SQL.  Which one are you working with?
0
 

Author Comment

by:dmalovich
ID: 37783740
MySql
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37783935
See here:  http://dev.mysql.com/doc/refman/5.0/en/string-literals.html   There is a link at the bottom of the page to Perl methods.
0
 

Author Closing Comment

by:dmalovich
ID: 37783950
Thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now