RE: Help?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On Thu, March 23, 2006 2:19 pm, Clinton, Rochelle A wrote:
> Hi Richard,
>
> WOW!  Thanks for such a quick response  -  this is just driving me
> crazy!  Not to mention consuming my time.
>
> I actually had been using the $line = in front of my replace attempts.
>
> Here is the exact offending code:
>
>             for ($i=0; $i<$line_length; $i++) {
>                $line[$i] = htmlspecialchars($line[$i]);
>                echo "debug: line$i is: " . $line[$i] . "<BR>";
>             }
>             $line[$line_length-1] = str_replace("</a>", "",
> $line[$line_length-1]);
>             echo "DEBUG: replaced def line is: " .
> $line[$line_length-1] . "<BR>";
>
> And the uncooperative output:
>
> debug: line0 is: ><a name = 73966552></a><a
> href="http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=Protein&list_uids=73966552&dopt=GenPept";
> >gi
> debug: line1 is: 73966552
> debug: line2 is: ref
> debug: line3 is: XP_866810.1
> debug: line4 is: </a> PREDICTED: similar to splicing factor,
> arginine/serine-rich 1
> DEBUG: replaced def line is: </a> PREDICTED: similar to splicing
> factor, arginine/serine-rich 1

Use "View Source" in your browser to see what REALLY is being printed
out...

The browser is interpreting your output, at all stages, and what you
see in the browser is not what you've got.

Word may not be exactly "WYSIWYG", but it tries...

A browser is *NOT* WYSIWYG to the Nth degree! :-)

For example, your ACTUAL data might ALREADY be:
&lt;/a&gt; PREDICTED:...

Or, it might be:
&lt;/&#97;&gt; PREDICTED:...

Or, it might be...

There are at least 3x3x3x3 possible combinations on this theme.  Throw
in UTF-8 characters being presented in Latin-1, and you've got that
times a thousand.

I SUSPECT that somebody has already done htmlentities() on your data,
and so you're *seeing* </a> in the browser, but your DATA is:
&lt;/a&gt;

So you need to do the str_replace() on THAT, not on what you see.

Or figure out where you already did htmlentities, and don't do that.

Only use htmlentities() at the last possible moment, at browser output.

Never [*] use htmlentities() on data for storage, nor processing.

Only at the last micro-second before spewing out to a browser should
your raw data be converted to a form suitable for browser display.

You'll just confuse yourself otherwise, with data converted too soon,
and not being what you expect when you look at it.

* There are bound to be exceptions to this, for some special 'expert'
situations...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux