socalnate Posted October 27, 2007 Share Posted October 27, 2007 I run a database that has a significant amount of apostrophe's (') as the ' in cd's. Problem is when I run an SQL query the SQL query is interpreting the apostrophe as part of a statement and it gives me an error. If I remove the apostrophe I don't get an error. Any ideas on how to fix this? I'm going to sleep on it... Nathan "I program, therefore, I am." Link to comment https://forums.phpfreaks.com/topic/74974-apostrophe-in-database-name-value-causes-sql-errorwhat-to-do/ Share on other sites More sharing options...
rajivgonsalves Posted October 27, 2007 Share Posted October 27, 2007 can you give the sql you are running you can escape the ' by using \ Link to comment https://forums.phpfreaks.com/topic/74974-apostrophe-in-database-name-value-causes-sql-errorwhat-to-do/#findComment-379156 Share on other sites More sharing options...
toplay Posted October 27, 2007 Share Posted October 27, 2007 rajivgonsalves is correct. All data should be escaped before an insert/update is attempted. Use one of these functions depending on your version of MySQL: http://us3.php.net/manual/en/function.mysql-real-escape-string.php http://us3.php.net/manual/en/function.mysqli-real-escape-string.php Link to comment https://forums.phpfreaks.com/topic/74974-apostrophe-in-database-name-value-causes-sql-errorwhat-to-do/#findComment-379227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.