For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2006 > wierd behaviour with jpg's and href's









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author wierd behaviour with jpg's and href's
auareanus

2006-07-01, 9:57 pm

I am seeing some frankly weird behaviour in a php script that I run.

The script pulls a set of URL's from a database and puts them into a <a
href...> ... </a> construct. The problem is that whenever I I pul a URL
that has a jpg extension it sends <--ref=..... -> (where ..... is the
URL and the label combined) to the page.

So I end up with:

<!--ref=http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg
http://www.bbc.co.uk/films/images/p..._hand_promo.jpg -->

instead of

<a
href=http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg>
http://www.bbc.co.uk/films/images/p..._hand_promo.jpg </a>

the code I am using is:

$turl=$row[0];
$rstring.="<span class=sitenumbers1><a href=";
$rstring.=htmlspecialchars($turl);
$rstring.=">";
$rstring.=$turl;
$rstring.="</a></span>\n";
echo $rstring;

Can anyone suggest what I should be looking a to stop this odd behaviour

Thanks
Al
Geoff Berrow

2006-07-02, 3:56 am

Message-ID: <e876p6$lhu$1$8300dec7@news.demon.co.uk> from auareanus
contained the following:

>$turl=$row[0];
> $rstring.="<span class=sitenumbers1><a href=";
> $rstring.=htmlspecialchars($turl);
> $rstring.=">";
> $rstring.=$turl;
> $rstring.="</a></span>\n";
>echo $rstring;
>
>Can anyone suggest what I should be looking a to stop this odd behaviour


You are missing a quote marks in your anchor tag, but that's not the
problem. Have you tried stripping out that snippet and running it on
its own? e.g.

<?php
$row[0]="http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg
";
$turl=$row[0];
$rstring.="<span class=sitenumbers1><a href='";
$rstring.=htmlspecialchars($turl);
$rstring.="'>";
$rstring.=$turl;
$rstring.="</a></span>\n";
echo $rstring;

?>

--
Geoff Berrow 0110001001101100010000000110
0011011010110110010001101111011001110010
11
1001100011011011110010111001110101011010
11
auareanus

2006-07-02, 7:56 am

Geoff Berrow wrote:

> You are missing a quote marks in your anchor tag, but that's not the
> problem. Have you tried stripping out that snippet and running it on
> its own? e.g.
>
> <?php
> $row[0]="http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg
> ";
> $turl=$row[0];
> $rstring.="<span class=sitenumbers1><a href='";
> $rstring.=htmlspecialchars($turl);
> $rstring.="'>";
> $rstring.=$turl;
> $rstring.="</a></span>\n";
> echo $rstring;
>
> ?>


Ok Geoff this is now even more confusing to me. When I run the code
snippet above in it's own file there is no problems and it does what I'd
expect.

When I stick the same code into a html wrapper (shown below) it produces :

<!--ref='http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg'
http://www.bbc.co.uk/films/images/p..._hand_promo.jpg -->

<--- begin code snippet --->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<LINK REL=StyleSheet HREF="format.css" TYPE="text/css">
</head>
<body>

<div class="resulttable" align="center">
<br>

<?php

$row[0]="http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg";
$turl=$row[0];
$rstring.="<span class=sitenumbers1><a href='";
$rstring.=htmlspecialchars($turl);
$rstring.="'>";
$rstring.=$turl;
$rstring.="</a></span>\n";
echo $rstring;


?>
</div>
</body>
</html>

<-- end code snippet -->



auareanus

2006-07-02, 6:57 pm

I have found out that the issue only occurs when <html> </html> tags are
used.

I don't know why these tags cause such behaviour and if anyone knows I
would be grateful if they could tell me.

At least I can get my output correct by removing the tags

Cheers
Al
Geoff Berrow

2006-07-02, 6:57 pm

Message-ID: <e88h8d$gol$1$8300dec7@news.demon.co.uk> from auareanus
contained the following:

>When I stick the same code into a html wrapper (shown below) it produces :
>
><!--ref='http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg'
>http://www.bbc.co.uk/films/images/p..._hand_promo.jpg -->
>
><--- begin code snippet --->


Works fine for me. The only difference is that I don't have your style
sheet but even so I don't know of anything that would turn an anchor
tag into a comment. You still have some quotes missing though (I missed
them before)

$rstring.="<span class='sitenumbers1'><a href='";

Try it with and without the stylesheet.



--
Geoff Berrow 0110001001101100010000000110
0011011010110110010001101111011001110010
11
1001100011011011110010111001110101011010
11
-Lost

2006-07-02, 6:57 pm

Missing quotes (and subsequent invalid markup) could cause the browser to misbehave,
*but*...

Since it is actual output, not due to the browser, then I think perhaps the original
poster's "html wrapper" is doing something specifically. Perhaps an errant regexp or
something seeing it and rewriting a comment tag as opposed to the A tag.

$0.02

-Lost


auareanus

2006-07-03, 3:57 am

-Lost wrote:
> Since it is actual output, not due to the browser, then I think perhaps the original
> poster's "html wrapper" is doing something specifically. Perhaps an errant regexp or
> something seeing it and rewriting a comment tag as opposed to the A tag.


I have found that whilst:

<?php
$row[0]="http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg
";
$turl=$row[0];
$rstring.="<span class=sitenumbers1><a href='";
$rstring.=htmlspecialchars($turl);
$rstring.="'>";
$rstring.=$turl;
$rstring.="</a></span>\n";
echo $rstring;

?>

works correctly

<html>

<?php
$row[0]="http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg
";
$turl=$row[0];
$rstring.="<span class=sitenumbers1><a href='";
$rstring.=htmlspecialchars($turl);
$rstring.="'>";
$rstring.=$turl;
$rstring.="</a></span>\n";
echo $rstring;

?>

</html>

does not. In fact I can put any HTMl markup around the PHP I want as
long as it dosen't have the <html> </html> tags. Having tried this on 2
different machines (one a Windows XP box running vanilla installs of
Apache 2.0.58/PHP 5.1.2, the other a Red Hat FC4 box with Apache
2.0.54/PHP 5.0.4, again vanilla install) I can only assume that I am
triggering some recipe in Apache. Although it is odd that I cannot find
anyone else that has the same problem.

Cheers
Al
Geoff Berrow

2006-07-03, 3:57 am

Message-ID: <e8a9hg$ib0$1$8300dec7@news.demon.co.uk> from auareanus
contained the following:

>does not. In fact I can put any HTMl markup around the PHP I want as
>long as it dosen't have the <html> </html> tags. Having tried this on 2
>different machines (one a Windows XP box running vanilla installs of
>Apache 2.0.58/PHP 5.1.2, the other a Red Hat FC4 box with Apache
>2.0.54/PHP 5.0.4, again vanilla install) I can only assume that I am
>triggering some recipe in Apache. Although it is odd that I cannot find
>anyone else that has the same problem.


Clutching at straws here but have you tried it without a stylesheet?

--
Geoff Berrow 0110001001101100010000000110
0011011010110110010001101111011001110010
11
1001100011011011110010111001110101011010
11
-Lost

2006-07-03, 3:57 am

"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:4aeha2lphtg9rf2p5r5k7k85llk3a48l0l@
4ax.com...

> Clutching at straws here but have you tried it without a stylesheet?


Not to mention, could you not just do:

$row[0] = 'http://www.bbc.co.uk/films/images/promos/trailers_right_hand_promo.jpg';

print '<span class="sitenumbers1"><a href="' . htmlspecialchars($row[0]) . '">' . $row[0]
.. '</a></span>' . "\n";

Whilst testing, to make it a little easier on your eyes? (Not to mention easier in
general.)

Lastly, I am quite serious (unless I missed something), your HTML source is being
"rewritten" with a COMMENT tag, correct? That means it is some previous code (perhaps
that "html wrapper" you mentioned before) that you are not showing us that is doing this.
PHP runs the script, outputs the HTML. If the markup shows a comment tag something in
your PHP put it there. Perhaps you could search the other source you are working with for
a comment tag and compare? If it is a HTML wrapper of some kind, would it not want to
place its own <html> et cetera?


Hope this helps.

-Lost


auareanus

2006-07-03, 6:57 pm

-Lost wrote:

> Lastly, I am quite serious (unless I missed something), your HTML source is being
> "rewritten" with a COMMENT tag, correct? That means it is some previous code (perhaps
> that "html wrapper" you mentioned before) that you are not showing us that is doing this.
> PHP runs the script, outputs the HTML. If the markup shows a comment tag something in
> your PHP put it there. Perhaps you could search the other source you are working with for
> a comment tag and compare? If it is a HTML wrapper of some kind, would it not want to
> place its own <html> et cetera?
>


Ok I've finally cracked it, I nwo know what is happening and feel quiet
foolish for posting to the group on this one.

I have Norton Internet security running. As soon as you turn off the Ad
blocking feature the commenting out stops.

Daft thing been an IT pro myself one of the first things I usual tell
people to check is the firewall, and here I forgot to check myself (I'm
just going to book myself in for some self LARTing)

Thanks to those that helped

Regards
Al
-Lost

2006-07-03, 6:57 pm

"auareanus" <newsgroup@rmve.caer-gai.rmv.co.rmv.uk> wrote in message
news:e8c5gp$ar9$1$8300dec7@news.demon.co.uk...

> I have Norton Internet security running. As soon as you turn off the Ad blocking feature
> the commenting out stops.


Jeez. I run several things myself that do that. ZoneAlarm being the main culprit in
writing out source. However, only Opera and Internet Explorer fall prey to this.

At least ZoneAlarm says something like <!-- zonealarm_privacy_insertion -->. Ah well.

Glad you figured it out.

-Lost


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com