Cyto Posted August 21, 2011 Share Posted August 21, 2011 Hi, I'm trying to delete a string that's single quoted. From: Cyto's to Cyto, but doesn't work. It works when I add 's to the string with stripslashes, but I can't seem to delete a quote from a string. Does someone know how? My $_post code: $name=mysql_real_escape_string(stripslashes($_POST["ename"])); Cheers Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/ Share on other sites More sharing options...
bfuzzeq Posted August 22, 2011 Share Posted August 22, 2011 Try str_replace or preg_replace Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260353 Share on other sites More sharing options...
teynon Posted August 22, 2011 Share Posted August 22, 2011 Your trying to delete a row from your database based on the name value? We would need to see how it is stored in the database. Is it stored as Cyto's or Cyto/'s? Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260357 Share on other sites More sharing options...
Cyto Posted August 22, 2011 Author Share Posted August 22, 2011 Your trying to delete a row from your database based on the name value? We would need to see how it is stored in the database. Is it stored as Cyto's or Cyto/'s? It's stored as Cyto and I add 's, it becomes Cyto's. Ok it works, but when I want to delete a row with 's in a string(Cyto's), it returns as Cyto's back instead of Cyto. P.S Cyto as string is a example, there are other words. Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260378 Share on other sites More sharing options...
teynon Posted August 22, 2011 Share Posted August 22, 2011 Please post the rest of the code. I don't know what you are trying to do right now. Please post code, don't just try to restate what you just said. Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260379 Share on other sites More sharing options...
Cyto Posted August 22, 2011 Author Share Posted August 22, 2011 Please post the rest of the code. I don't know what you are trying to do right now. Please post code, don't just try to restate what you just said. I'm trying to delete a row with a quote in a string and add a row with a quote in a string. The adding works with stripslashes, but the deleting part... I'm stuck there. Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260475 Share on other sites More sharing options...
silkfire Posted August 22, 2011 Share Posted August 22, 2011 Maybe: UPDATE `table` SET `string` = REPLACE(`string`, "'", '') If you need some kind of filtering add a WHERE clause. Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260477 Share on other sites More sharing options...
Cyto Posted August 22, 2011 Author Share Posted August 22, 2011 Maybe: UPDATE `table` SET `string` = REPLACE(`string`, "'", '') If you need some kind of filtering add a WHERE clause. Thx, but nvm. I figured it out myself. I added mysql_real_escape_string() in the where clause. It added a slash to the quoted strings. Worked. Thank you too, teynon. Quote Link to comment https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260479 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.