php - Escaping a string from database that goes on alt attribute -


this should easy don't see i'm missing here:

i have database , want alt attribute populated it.

i have code follows:

  <img src="admin/uploads/retouch/'.$list->thumbnail.'" class="thumb-image" alt="'.utf8_encode(addslashes($list->titulo)).'" /> 

and happens in case what's inside "titulo" in database has " on , result in code:

  <img ti!\""="" por="" ¡hazlo="" manos.="" en="" estÁ="" prestaciones="" tus="" mejorar="" alt="\" class="thumb-image" src="admin/uploads/retouch/noticia_default.png"> 

the sentence database is: "mejorar tus prestaciones estÁ en tus manos. ¡hazlo por ti!"

you should using htmlspecialchars not addslashes, utf8 option!

alt="'.htmlspecialchars($list->titulo, ent_quotes, 'utf-8').'" 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -