Welcome Guest, Not a member yet? Register   Sign In
database records with ' in the data
#1

[eluser]filip_de_backer[/eluser]
Hi,

This is the code:
$adres = $list['l_adres'] . " " . $list['l_postcode'] . " " . $list['l_gemeente'];

$list[''] --> this is a column from teh database.

But in the l_adres, there is the character '

When I use the $adres in a html control, the data gets lost because of:
echo "<input id='adresHidden' name='adresHidden' type='hidden' value='" . $adres . "'/>";

How can I convert it to another character?
Is there a CI helper methode that converts special characters to html codes?

thanks,

Filip
#2

[eluser]jplanet[/eluser]
use:

htmlentities($adres)
#3

[eluser]JoostV[/eluser]
or
Code:
echo '<input id="adresHidden" name="adresHidden" type="hidden" value="' . $adres . '"/>';

or
Code:
$this->load->helper('form');
echo form_hidden('adresHidden', $adres);
Note that form_hidden() will not attach the id attribute to your hidden element.
#4

[eluser]jplanet[/eluser]
[quote author="JoostV" date="1267887649"]or
Code:
echo '<input id="adresHidden" name="adresHidden" type="hidden" value="' . $adres . '"/>';
[/quote]

Keep in mind that will break if the value of $adres contains a double-quote...
#5

[eluser]JoostV[/eluser]
[quote author="jplanet" date="1267888128"]
Keep in mind that will break if the value of $adres contains a double-quote...[/quote]
True Smile




Theme © iAndrew 2016 - Forum software by © MyBB