tags:

views:

69

answers:

4

Hey Guys,

I have a crazy situation that I cannot figure out:

I have this string:

$description = "<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;

and sometimes the printout looks like this:

<a href='http://www.domain.com'&gt;&lt;img src='http://www.domain.com/image.jpg' border=0 ></a> Other Text

and other times it looks like this.

<a href=''><img src='' border=0 ></a> Other Text

I would think that something is happening to my variables, but if I do the following:

  $description = $link."<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;

then it outputs the $link variable in front of the html 100% of the time:

http://www.domain.com&lt;a href=''><img src='' border=0 ></a> Other Text

What is going on!?

--- SOLVED ---

I had parsing scripts that were misbehaving removing the links. The solution should of been intuitive but I thought the string was not being ran through any other functions. too many LOC. Thanks for the support! For those of you who stumble upon this check your parsing functions!

A: 

You might have misspelled the second link variable. PHP will not warn you when this happens, but will silently give you a new, empty variable.

geon
A: 

What is the intention of that .$description at the end of the line in which you're also assigning a value to $description? If I execute your first line in PHP, my interpreter complaints with

  PHP Notice:  Undefined variable: description in C:\Temp\test.php on line 4

Are you sure that $description has already a value each time you execute that line?

jschulenklopper
A: 

Check what's in your $link variable as if you have any 's in it it may be interrupting your html. That or any other symbols.

Thomas Clayson
+2  A: 

Turn error reporting on to see more information during development...

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
Chris