yhi Posted December 2, 2017 Share Posted December 2, 2017 i am using php to generate some stuff & using javascript to insert those stuff in my firebase DB but now the problem is some of those generated strings contain some html anchor tag in them so my JS script is refusing them & they are not getting inserted because they contain single quote i tried to replace single quote with double quote but then firebase is adding a backslash before every " so those anchor tags are not working when i am showing DB on a page so far i was only able to think about one solution that i should remove all single & double quote & href will still work & i can replace space with %20 so the link will not get broke example generated string by my php hello <a href='https://forums.phpfreaks.com'>PHP freaks</a> my JS script [API keys] firebase.initializeApp(config); var database = firebase.database(); var ref = database.ref('phpfreaks'); var data = { text: '$text1', text2: '$text2' } ref.push(data); PS i cant remove single quote before my variable in JS script if i do so the data will not get entered... Quote Link to comment Share on other sites More sharing options...
BigB Posted December 3, 2017 Share Posted December 3, 2017 (edited) Would htmlspecialchars() work? Edited December 3, 2017 by BigB 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.