CodeIgniter Forums

Full Version: passing special character to MySQL SP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dinomycle[/eluser]
i am calling a stored procedure like below in my CI +MySQL web application

Code:
$id = 3;
        $name = "ABC_(CDE)";
$sql = "call getInfo(?,?);" ;
$query=$this->db->query($sql,array($id,$name));

but i was not getting the any query result, after enabling mysql debug, below code was getting passed to the MySQL SP

Quote:518 Query call getInfo('3','ABC_(CDE)')

so i believe the SP is searching for the string with html encoding. How to pass the variable without html encoding when i call the $this->db->query()

thanks for the help
dino

El Forum

[eluser]Aken[/eluser]
You cannot disable query escaping when using binds. You'll have to use $this->db->query() without it.

El Forum

[eluser]dinomycle[/eluser]
hello aken
thanks for the reply....
means, can u explain ..i am not an expert in this... how should i do this

there is difference in what i told before...
if i put $name = "ABC_(CDE)"; it works when i pass to the SP...but in my actual code, $name is coming as a function argument and i pass it directly to the SP...in this condition only the problem coming...

Code:
function1($name)
{
  $id = 3;
        
$sql = "call getInfo(?,?);" ;
$query=$this->db->query($sql,array($id,$name));
}
so when i checked the string length of the $name it is coming as 17 and if i do $name = "ABC_(CDE)"; coming as 9... so is it because of some UTF encoding ???

thanks for support
dino

El Forum

[eluser]Aken[/eluser]
It could be.

El Forum

[eluser]dinomycle[/eluser]
if i use the active record method also i get the same issue , can someone help me out

thanks for the help
dinomycle