webmasters
webmasters

Reputation: 5831

Turn & into amp for URL's imported into database

I import some URL's from an XML feed.

$myurl = 'http://www.myurl.com?value1=val&value2=val&value3=val

The problem is when I try to validate my code, I need &amp instead of &

Upvotes: 0

Views: 79

Answers (1)

Quentin
Quentin

Reputation: 943537

You need & when you insert the text into an HTML or XML document, not when it goes anywhere near a database.

If you are generating HTML, then put your text through htmlspecialchars() to turn it into HTML.

If you are generating XML, then use an XML library to generate it. Don't build it by mashing strings together.

Upvotes: 2

Related Questions