Jump to content

DISPLAYING, not entering!, apostrophes?


Soulhunter74

Recommended Posts

Hi,

I've got the following problem. An item in my DB has a value like this: The carpenter's roof.
With my current coding the web page only displays: The carpenter

My coding:

***
echo "<a href='projets_encours_details.php?ID=$row[2]'><img src='images/home/$row[0]' border='0'  class='homeThumb' alt='projet en cours' title='$row[3] $row[4] (début étude: $row[5])' width='200' height='80' /></a><br>$row[1]";
***

The problem seems to be with the 'title=' part. It seems like the code interprets the ' as marking the end of the string. How do I correct this?

Thanks a lot!

Jerome
Link to comment
https://forums.phpfreaks.com/topic/24738-displaying-not-entering-apostrophes/
Share on other sites

Use double quotes in your html instead of single quotes:
[code]
<?php

echo <<<_HTML
<a href="projets_encours_details.php?ID={$row[2]}"><img src="images/home/{$row[0]}" border="0" class="homeThumb" alt="projet en cours" title="{$row[3]} {$row[4]} (début étude: {$row[5]})" width="200" height="80" />< /a>{$row[1]}
_HTML;

// Or escape them in normal echo

echo "<a href=\"projets_encours_details.php?ID=$row[2]\"><img src=\"images/home/$row[0]\" border=\"0\"  class=\"homeThumb\" alt=\"projet en cours\" title=\"$row[3] $row[4] (début étude: $row[5])\" width=\"200\" height=\"80\" />< /a>$row[1]";

?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.