Solved

HTML vs PHP generated code

Posted on 2004-10-07
4
244 Views
Last Modified: 2010-08-05
There must be a simply answer to this but it's annoying the hell out of me. Please help.

(what I am asking may seem pretty pointless but it is the root of my problem)

In my web page I have the HTML code:
<span class="style6" id="TestSpan" onMouseOver="MM_changeProp('TestSpan','','innerHTML','New text','SPAN')">Text in span</span>

I also have:
<?php
echo "<span class='style6' id='TestSpan1' onMouseOver='MM_changeProp('TestSpan1','','innerHTML','New text1','SPAN')'>Text in span1</span>";
?>

I must lack some basic understanding... but why does the HTML work and the php doesnt???????

When I view the webpage and go to view/source the output is the same (except for double and single quote differences).
0
Comment
Question by:michaelbrewitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 30 total points
ID: 12253547
Its a quote issue, your switching between single and double quotes the wrong way when you use the php version, instead escape the double quotes in this case using backslash, eg:

<?php
echo "<span class=\"style6\" id=\"TestSpan\" onMouseOver=\"MM_changeProp('TestSpan','','innerHTML','New text','SPAN')\">Text in span</span>";
?>
0
 
LVL 33

Assisted Solution

by:snoyes_jw
snoyes_jw earned 20 total points
ID: 12253549
That's exactly why - the double and single quote differences.  For the HTML version, you've got
"MM_changeProp('***we're still inside double quotes***')"

The PHP version has
'MM_changeProp('***we just lost our quotes

Change the php version to
onMouseOver=\"MM_changeProp...'SPAN')\">


0
 
LVL 1

Author Comment

by:michaelbrewitt
ID: 12253681
Thanks - couldn't ask for more.

I just copied Diabs code in and it worked (with minor typo tweak)

Snoyes - you helped me further understand - thanks
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12254274
No problem :)

what was the typo btw? couldn't see a problem with the escaping, i copied and edited the html version or the code you posted so maybe it originated there?...

Anyway, best of luck with your code.

|)iablo
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I remove "" from json_encode 5 34
How to close my php post page. 3 40
Code planning methods/tools? 5 53
Posting and receiving data with JSON in PHP 12 32
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question