March 3, 2013
PHP, quotes, and .html
Question by idigyourpast
I’m having a bit of a brain fart with this one line:
jQuery("#image-div").html("<img src='get.php?id_no='" + id + ">");
I’m trying to concatenate the <img>
tag with a variable id
but I can’t seem to get the quotes right. Stupid mistake, I know, but it’s just eluding me. Can I get a little help?
Answer by Matthew Blancarte
Looks like you were misplacing an apostrophe.
jQuery("#image-div").html("<img src='get.php?id_no=" + id + "'>");
Answer by Starx
You have an misplaced single quote in your code.
jQuery("#image-div").html("<img src='get.php?id_no='" + id + ">");
// ^ This one here
It should be
jQuery("#image-div").html("<img src='get.php?id_no=" + id + "'>");
// ^ Should be here