I have a basic php/mysql cms. When I go to save a textfield that contains the char "&" it seems to be updating the database with "&"
I'm sure it suddenly started happening, could this be a mysql update or configuration issue or...?
| SitePoint Sponsor |



I have a basic php/mysql cms. When I go to save a textfield that contains the char "&" it seems to be updating the database with "&"
I'm sure it suddenly started happening, could this be a mysql update or configuration issue or...?

Hi there,
This might be an encoding issue.
Let me understand your problem:
You have a CMS.
You enter text into your CMS (for example to update a page on your site).
You save your changes.
You look at your website and see that the & characters which you entered in the CMS are being displayed as &
Is that correct?
How well do you know your JavaScript from your jQuery?
Check out SitePoint's latest JavaScript challenge
My blog



No, it's the text that is actually updated to the database that is converted to the &
The text field has "&", the updated table contains "&"


Right, because the CMS is likely encoding it to be stored into the database. When it is read from the database, the & is the appropriate HTML entity for displaying purposes.
Granted, it is unnecessary to encode & in a database, but it is absolutely necessary to encode it when writing it as output for a user to see on your site.





Thanks guys, I'll look into the php then... just wanted to rule out mysql. Strange how it's suddenly started happening, almost like a version update of php or mysql had triggered the change in processing


Have you recently upgraded the CMS? Could be part of the CMS upgrade. On a side note, I've asked that this thread be moved to the PHP forum.



Homemade CMS! Tracked down the problem, htmlspecialchars being applied. Doh!


Bookmarks