Reputation: 3
I retrieve some database entries with php mysqli SELECT.
Some of the entries contain a single quote (ie : L'avant du bâtiment). This generates a parse error and breaks my webpage down.
Here is the query :
$themes = ee()->db->select('field_id_46')
->from('channel_data_field_46')
->get();
if ($themes->num_rows() > 0)
{
foreach($themes->result_array() as $row)
{
$themesConcat = $row['field_id_46'];
echo $themesConcat;
}
}
How can I get rid of the quotes in the field_id_46 entries ?
Please note that the db Class belongs to the ExpressionEngine CMS core and that it should not be modified.
Upvotes: 0
Views: 573
Reputation: 26
You can use str_replace()
function for character replacement.
The modified code as:
echo str_replace("'", "", $themesConcat);
Hope this helps you.
Upvotes: 1
Reputation: 606
You need to escape the character. You can do it with php's method addslashes like this:
echo addslashes($themesConcat);
Upvotes: 1