Update:
I'm still confused as ever. Can someone please reply to my last comment?
If all my data (+title1+ and +title2+ in this example -- see below) is sanitized using PHP do I need to worry about javascript as well? I'm concerned about my use of title='"+title2+"' (the apostrophes is my concern) in my code below.
html\javascript:
<div id="verification"></div>
<script>
function update() {
$.ajax({
url: 'update.php', //php
data: "",
dataType: 'json',
success: function (data) {
//on receive of reply
var title1 = data[0];
var title2 = data[1];
$('#verification').html("<img src=images/test"+title1+".gif title='"+title2+"'></img>"); //output to html
}
});
}
</script>
json response
["1","test test test"]
output (by Mouseover text with Title)
test test test
php (php sanitizing omitted)
$result = mysql_query("SELECT title1, title2 FROM users WHERE username = '$foobar'")
or die(mysql_error());
$array = mysql_fetch_row($result);
echo json_encode($array);