andz Posted June 2, 2009 Share Posted June 2, 2009 consider the following string including quotes, how do i removed the inner quotes only??? '%'testinghere'%' Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/ Share on other sites More sharing options...
Alt_F4 Posted June 2, 2009 Share Posted June 2, 2009 how does that NOT throw an error?? you could do: $str = str_replace("'%'","'%","'%'testinghere'%'"); Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/#findComment-847681 Share on other sites More sharing options...
DarkSuperHero Posted June 2, 2009 Share Posted June 2, 2009 that particular string would need to be wrapped with different quotes (double quotes) to not throw an error otherise it would need to be excaped..... //notice Alt_F4's string was also wrapped in double quotes containing the single inner quotes.. $str = str_replace("'%'","'%","'%'testinghere'%'"); //this will be ok... $someVariable1 = '%\'testinghere\'%'; //escaped the inner quotes with backslash \ ..... //wrong way.... will throw an error $someVariable2 = '%'testinghere'%'; Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/#findComment-847729 Share on other sites More sharing options...
andz Posted June 2, 2009 Author Share Posted June 2, 2009 how can i apply this on a solution? like str_replace thanks that particular string would need to be wrapped with different quotes (double quotes) to not throw an error otherise it would need to be excaped..... //notice Alt_F4's string was also wrapped in double quotes containing the single inner quotes.. $str = str_replace("'%'","'%","'%'testinghere'%'"); //this will be ok... $someVariable1 = '%\'testinghere\'%'; //escaped the inner quotes with backslash \ ..... //wrong way.... will throw an error $someVariable2 = '%'testinghere'%'; Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/#findComment-847784 Share on other sites More sharing options...
andz Posted June 2, 2009 Author Share Posted June 2, 2009 here's the complete code that where i want it to apply. SELECT * FROM `test` WHERE `user` LIKE '%'coder'%' Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/#findComment-847788 Share on other sites More sharing options...
Maq Posted June 2, 2009 Share Posted June 2, 2009 In your original post, you said you want to remove the inner single quotes. If you want to keep them, then you need to escape them, if not, then you can remove them. Which do you want to do? Quote Link to comment https://forums.phpfreaks.com/topic/160629-help-with-quotes/#findComment-847850 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.