[RESOLVED] rollover image include file
i just reworked my site so that now each page is almost entirely comprised of style sheets and include files. pretty cool and organized.
the only niggling problem i have now, after sorting out all the syntazx errors caused by quoatations, etc, is that the mouse rollover function in one of the files does not work. the link still works and the "off" image displays, but the image will not change on mouseover. and if i simply replace the original code, it works fine.
here is the code in the include (should be pretty straight-forward non-php stuff):
<?php echo '
<img name="image1" src="http://www.jamesmehaffey.com/images/webcam/hummingbird-off01.png" alt="Hummingbird" width="50" height="58" border="0" /></a>
i'm not getting any errors or anything that would point to the source of the problem, so i'm a bit stuck. it's not a big deal, but it would be useful to know for future reference.
Looks to me like you have your single- and double-quotes reversed at the end of the two onmouseover lines.
On a side note: since it appears there are no PHP variables/functions within all that text, why not just exit out of PHP mode at that point instead of doing a big echo?
well spotted, nogdog. that's what i get for staring at the screen for so long... it's almost always something stupid like that.
to answer your question though, this is just a snippet of code that appears on every page. so i just created this simple echo and put it in an include file.
Even as a PHP include file, it does not have to be PHP code. Both of these files would give the same functional result if included into a PHP script:
Originally Posted by mimewear
echo "<p>This is a test.</p>\n";
<p>This is a test.</p>
Output of index.php would be:
It's not a big deal, but it saves you some typing and escaping of quotes, and may process just a tad faster. It's also probably a bit easier to debug. If you do need to echo large chunks of HTML, you might consider using the "heredoc" syntax, which makes the quoting a bit simpler, since the string itself is not quoted in the usual way:
This is a test.
This is a test.
<p onclick="foo('bar');">This is a test.</p>
<p onclick="bar('foo');">It is only a test.</p>
/* the "END;" must not have any white-space before it */
sorry, i misunderstood you. a perfect example of why it's important to take breaks and sleep sometimes. yeah, i see what you mean - that makes life a little easier. still though, it was a good if pointless exercise in proper syntax.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)