Do arrays not store inverted commas and apostrophes?

This seems to be the case with a project I'm working on and it's very annoying.

I'm pulling small strings from a DB, some of which contain inverted commas or apostrophes, and when I try echo them the ones with the apostrophes or inverted commas only show the first part of the string before them (inverted commas, apostrophes). Anyone know how I could solve this issue?

Recommended Answers

All 2 Replies

Ok, you can all just ignore this thread completely. I was being an idiot :P ;)

You need to escape certain characters otherwise they do funky things to your PHP.

Best way is to escape them (or convert them to HTML enitities) when they are put into the database (Otherwise they may run riot on the database) and then unescape any escaped characters when you echo them.

There is plenty of info around on escaping/sanitizing strings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.