Search code examples
sqlcodeigniterquote

Allow single quote in sql query


I want to update my sql table , but in my case I am getting error look like this

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ivision '' at line 1

$name = "A'nme";

$this->db->update("users",["name" => $name]);

My project based on Codeigniter

How can I solve this problem ?


Solution

  • Double up and use single quotes to see it better: How to insert a value that contains an apostrophe (single quote)?

    $name = 'A''nme';