JohnnyDoomo Posted June 7, 2016 Share Posted June 7, 2016 I'm very new to php, and I'm trying to keep ampersands from changing from & to & I have a url that contains multiple ampersands. I'm trying to hand this variable off to an API line for a local url shortener script. However, the url shortener isn't working, and when I check what it has put into the mysql database, it's saving the url with & instead of &. The page after submitting the form contains ampersands. On that page is the link for the same page, but being processed by the url shortener. This is the link that is wrong. I've echo'ed out my variable I'm handing the API and the echo shows ampersands, and I've even checked the source of the html page where the echo is being displayed, and even in the source code, it shows ampersands not & But when I check the db, the insertion for that short url page, has the page under the correct long url, but all ampersands are switched to & Do I need to do something more with my variable before handing it to the API? Do I need to contact the url shortner programmer? Is there something I can search for in the url shortener script, to keep it from "cleaning" my urls I hand it? Could this be some server setting that is causing this issue? Any help on this problem would be greatly appreciated, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/301313-prevent-ampersands-from-changing/ Share on other sites More sharing options...
Jacques1 Posted June 7, 2016 Share Posted June 7, 2016 Without the exact code, it's hard to tell what's wrong. Is the URL shortener script publicly available? HTML entities like & in the wrong places are often caused by poorly written code which blindly applies htmlspecialchars() or htmlentities() to all input “to make it secure”. That's what you could search for. Besides that, we can only speculate. By the way, your own code should apply HTML-escaping to the URL before it's printed so that ampersands appear as & in the HTML source. Otherwise you may run into syntax conflicts or even security vulnerabilities. Quote Link to comment https://forums.phpfreaks.com/topic/301313-prevent-ampersands-from-changing/#findComment-1533475 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.