dennismonsewicz Posted December 29, 2008 Share Posted December 29, 2008 How do you place an apostrophe in a SQL statement? EX: INSERT INTO table (row1, row2) VALUES ('Hello', 'Don't Try'); Quote Link to comment Share on other sites More sharing options...
.josh Posted December 29, 2008 Share Posted December 29, 2008 escape it \' in practical terms (like if you're using vars instead of hardcoding), depending on your situation, you can use addslashes or mysql_real_escape_string Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 29, 2008 Author Share Posted December 29, 2008 I am writing a SQL file and was wondering... i am more used to doing it using PHP to process but i have to write a SQL file for this particular project. Will escaping it your way still work? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 29, 2008 Author Share Posted December 29, 2008 figured it out.. use two apostrophes instead of one.. EX: INSERT INTO table (row1, row2) VALUES ('Hello', 'Don''t Try'); Quote Link to comment Share on other sites More sharing options...
.josh Posted December 29, 2008 Share Posted December 29, 2008 yes, you can escape quotes. INSERT INTO table (row1, row2) VALUES ('Hello', 'Don\'t Try'); Or you can use double quotes around the values like so: INSERT INTO table (row1, row2) VALUES ("Hello", "Don't Try"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.