hlstriker Posted October 23, 2006 Share Posted October 23, 2006 Hi, I am trying to add html to a php variable so it can then send the HTML code to a field in my database. (Yes I want the html code itself to be sent to the database!)I get "unexpected T_STRING" error for this code...[code]$html = "<tr> <td valign='top' align='center' bgcolor='#212121'> <a href='#' onmouseover="roll_over('name', 'http://www.mysite.com/image-hover.jpg')" onmouseout="roll_over('name', 'http://www.mysite.com/image.jpg')"> <img border='0' src='http://www.mysite.com/image.jpg' name='name'></a> </td></tr>"[/code]The error line is where I start the link. I think it is because of the double quotes, but I don't know how to bypass this because if I put the single quotes in the link, the javascript won't function.If someone could tell me how to do this please do! Thanks! Link to comment https://forums.phpfreaks.com/topic/24803-adding-html-to-php-variable/ Share on other sites More sharing options...
fert Posted October 23, 2006 Share Posted October 23, 2006 use \" Link to comment https://forums.phpfreaks.com/topic/24803-adding-html-to-php-variable/#findComment-112966 Share on other sites More sharing options...
fiddy Posted October 23, 2006 Share Posted October 23, 2006 Hi,You are getting this error because you use just ", you should use \" becuse you have started with ".i feel its better to do like this.So that you can add HTML as you wish without worrying about the quotes and double quotes$html = <<START<tr> <td valign='top' align='center' bgcolor='#212121'> <a href='#' onmouseover="roll_over('name', 'http://www.mysite.com/image-hover.jpg')" onmouseout="roll_over('name', 'http://www.mysite.com/image.jpg')"> <img border='0' src='http://www.mysite.com/image.jpg' name='name'></a> </td></tr>START; Link to comment https://forums.phpfreaks.com/topic/24803-adding-html-to-php-variable/#findComment-112975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.