How to insert texts that contain apostrophe?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

How to insert texts that contain apostrophe?

Post by ljCharlie »

Here's what I'm trying to do. I'm trying to insert this:
INSERT INTO photoGallery (sectionID,fileName,path,category,description,comments,insertDate) VALUES (8,'Reunion282.jpg','images/gallery','current',''53 '54 '55 Basketball Reunion',NULL,'2004-11-05')
and the error is:
You have an error in your SQL syntax near '53 '54 '55 Basketball Reunion',NULL,'2004-11-05')' at line 1
So I'm guessing it has to do with the apostrophes that are in the '53 '54 '55. How do I solve this problem so that I can insert the apostrophes but get rid of this error?

ljCharlie
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Never mind, I got it working now.

ljCharlie
swdev
Forum Commoner
Posts: 59
Joined: Mon Oct 25, 2004 8:04 am

Post by swdev »

use the [php_man]mysql_escape_string[/php_man] PHP function to handle all the weird characters than can cause SQL to barf
Post Reply