Jump to content


Photo

Adding html to php variable?


  • Please log in to reply
2 replies to this topic

#1 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 23 October 2006 - 03:57 AM

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...
$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>"

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!

#2 fert

fert
  • Members
  • PipPipPip
  • Advanced Member
  • 1,114 posts

Posted 23 October 2006 - 04:03 AM

use \"

Si hoc legere scis nimium eruditionis habes
Gentoo Linux 2007.0 Firefox 2

#3 fiddy

fiddy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 23 October 2006 - 04:41 AM

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;


:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users