I thought I could use this to remove the quotes:
Code: Select all
$string = ereg_replace(""", "",$row->communication);Can anyone help me with this please? I've done it before, but the code just wont work.
Moderator: General Moderators
Code: Select all
$string = ereg_replace(""", "",$row->communication);Code: Select all
function convert_smart_quotes($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151));
$replace = array("'",
"'",
'"',
'"',
'-'); //hyphen, could also be –
return str_replace($search, $replace, $string);
}
I assume people entered them for a reason and display them, applying escaping where necessary.simonmlewis wrote: How do you remove Apostropies and Double Quotes?
simonmlewis wrote: I am trying to just render the result of a field in a table, but because people have entered " or ' into the table, the render goes a bit wrong.
Code: Select all
<div>
<?php echo htmlspecialchars($string, ENT_QUOTES, "UTF-8"); ?>
</div>
Code: Select all
<td valign='top'><a href='index.php?page=emailid&id=$row->id&head=email detail' style='text-decoration: none' title='";
htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8");
echo ">$row->reason</a></td>Code: Select all
<td valign='top'><a href='index.php?page=emailid&id=<?php echo htmlspecialchars($row->id, ENT_QUOTES, "UTF-8");?>&head=email%20detail' style='text-decoration: none' title='<?php echo htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8");?>'><?php echo htmlspecialchars($row->reason, ENT_QUOTES, "UTF-8");?></a></td>
Code: Select all
<td valign='top'><a href='index.php?page=emailid&id=$row->id&head=email detail' style='text-decoration: none' title='htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8");>$row->reason</a></td>
<td valign='top' nowrap><a href='index.php?page=emailid&id=$row->id&head=email detail' style='text-decoration: none'>$row->website</a> </td>Now this is a problem you have to fixsimonmlewis wrote:Since it is ALL within the PHP code
Code: Select all
echo '
<td valign="top"><a href="index.php?page=emailid&id=' . $row->id . '&head=email detail" style="text-decoration: none;" title="' . htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8") . '">' . $row->reason . '</a></td>
<td valign="top" nowrap><a href="index.php?page=emailid&id=' . $row->id . '&head=email detail" style="text-decoration: none">' . $row->website . '</a> </td>';Code: Select all
echo '<td valign="top"><a href="index.php?page=emailid&id=$row->id&head=email detail" style="text-decoration: none" title=' . htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8") . '>$row->reason</a></td>';
$row->reason
Code: Select all
echo '<td valign="top"><a href="index.php?page=emailid&id=' . $row->id . '&head=email detail" style="text-decoration: none;" title="' . htmlspecialchars($row->communication, ENT_QUOTES, "UTF-8") . '">' . $row->reason . '</a></td>';
It's not inside the dots! It's OUTSIDE of the single quotes. This is the most basic of PHP, so better get reading:simonmlewis wrote:Perfect - thanks.
I couldn't see why I would have to put the $row->reason inside the dots. Still can't really. And I thought I knew my PHP!! lol
The dots anctually stand for the concatenation function in PHP - that is, adding one or more string together. If you write a variable inside a string and echo it like this:simonmlewis wrote:I couldn't see why I would have to put the $row->reason inside the dots.
Code: Select all
<?php $varA = "this text";
echo "Echoing $varA"; ?>Code: Select all
<?php $varA = "this text";
echo "Echoing " . $varA; ?>