?
Solved

Apostrophe Problem

Posted on 2006-05-06
2
Medium Priority
?
289 Views
Last Modified: 2013-12-25
I am coming up with a problem when I submit text with an apostrophe in the text from a textbox to mysql using perl.

Error mesage I get is:
DBD::mysql::st execute failed: 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 't

When for example i use the word "doesn't" in the text.

I know I should be using escaped characters but I can't seem to get the apostrophe part working.  

For newline I use the following command:
$text =~ s/\n/<br>/g;

Can you please help.
0
Comment
Question by:falthorn
2 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 1000 total points
ID: 16627084
MySQL requires single quotes to be deleimited by another quote such as:  d o e s ' ' t.

If you use placeholder, DBI will handle all the quoting for you
$sth = $dbh->prepare("INSERT INTO table(foo,bar) VALUES (?,?");
$sth->execute( $foo, $bar);  # $bar  can contain single quotes
0
 

Author Comment

by:falthorn
ID: 16627105
Thank you teraplane,  it worked a treat.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

612 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