0

I have stored the following code in a MySQL text field:

'<img class="marginRight roundPicture" src="'+pictureUrl+'"/><a href="'+link+'" target="_blank" />'+name+'</a>'

using an Ajax $.post in jQuery. pictureUrl, link and name are variables from JavaScript. I store the code successfully in my MySQL database.

When I return the code from MySQL using Ajax and update a table with it, the pictureUrl link works, but the link in the <a> tag doesn't. The links look like this:

pictureUrl = https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xat1/v/t1.0...

link = https://www.facebook.com/app_scoped_user_id/163665554...

I put ... at the end because they are too long to display here.

If I copy the link from the code and access it manually in the browser it works, but for some reasons it doesn't work when updating the code automatically in the page.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

1 Answers1

0

It is a string when it comes from the database. In order to display it correctly, you need to convert it to HTML format using html_entity_decode().

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119