Khirad Zahra
Khirad Zahra

Reputation: 893

Backslash and apostrophe not storing in MySQL using CodeIgniter properly

Config file.

$config['global_xss_filtering'] = TRUE;

Here is my string that I want to insert into the database.

$str ='Provence-Alpes-Côte d'Azur, France';

and I have converted this string into this using add_slashes function:

Provence-Alpes-Côte d\'Azur, France

But in the database it keeps storing like this:

'Provence-Alpes-Côte d'Azu';

This adds &#039 instead of \'

How can I fix this?

Upvotes: 0

Views: 227

Answers (1)

Alex
Alex

Reputation: 9265

Disable xss_filtering:

$config['global_xss_filtering'] = FALSE;

xss filtering is doing this to escape any potential issues as that kindof slashing is how people do injection.

Generally even CodeIgniter devs say to avoid it:

The ‘global_xss_filtering’ setting is DEPRECATED and kept solely for backwards-compatibility purposes. XSS escaping should be performed on output, not input!

https://www.codeigniter.com/user_guide/libraries/input.html

Upvotes: 1

Related Questions