Welcome Guest, Not a member yet? Register   Sign In
MYSQLI escape string
#1

[eluser]jzmwebdevelopement[/eluser]
I am currently updating a section of code that uses mysql currently the escape string is structured like this:
Code:
$product_name = mysql_real_escape_string(trim($_POST['product_name']));
and works fine.

My issue is when I change the above string to
Code:
$product_name = mysqli_real_escape_string($database, (trim($_POST['product_name'])));
and declare the following:
Code:
$database = $this->load->database();
above it I get the error that its NULL

How do I escape a string with CI?
#2

[eluser]LifeSteala[/eluser]
You should really be using CI native form validation class and use xss_clean which does all of that automatically. Also using $this->input->post() does the cleaning as well.

Reference:
http://ellislab.com/codeigniter/user-gui...greference
http://ellislab.com/codeigniter/user-gui...input.html




Theme © iAndrew 2016 - Forum software by © MyBB