Posts: 4,363
Threads: 101
Joined: Oct 2014
Reputation:
146
mysql_real_escape_string — Escapes special characters in a string for use in an SQL statement.
If your using CI it escapes the query for you.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Posts: 56
Threads: 28
Joined: Apr 2015
Reputation:
0
I ended up using a str_replace to get those quotes escaped before making a javascript array out of the data. Wasn't really using it to insert data going into a table... that's where the data is coming from.
Posts: 671
Threads: 17
Joined: Oct 2014
Reputation:
37
04-24-2016, 05:50 AM
(This post was last modified: 04-24-2016, 05:51 AM by ivantcholakov.)
@cupboy
1. You are trying to apply a function to a column in the returned array. What this function is going to do, what the goal is?
2. mysql_real_escape_string() is a function for escaping value when you prepare a SQL statement. You apply it on the returned result. Why?
3. mysql_real_escape_string() belongs to a certain SQL driver that is deprecated and as far as I know removed in PHP7.
4. mysql_real_escape_string() probably does not match to the current database driver that CodeIgniter uses. If you need such an escaping, see in documentation what routines the Database class provides.
Remove this code, explain exactly what you intend to do.
Posts: 56
Threads: 28
Joined: Apr 2015
Reputation:
0
04-24-2016, 04:11 PM
(This post was last modified: 04-24-2016, 04:11 PM by cupboy.)
1. The goal is to put the results into a javascript array that requires the same type of escaping as an SQL statement
3. Fixed that to be mysqli instead.
I've fixed all this and the code is fine now.