I want to escape string in magento, but when I am using mysql_real_escape_string, i am getting warning.
mysql_real_escape_string
Warning: mysql_real_escape_string()
Use this to escape a string for a query and add the surrounding single quotes:
Mage::getSingleton('core/resource')->getConnection('default_write')->quote($string);
You can look up Varien_Db_Adapter_Pdo_Mysql for further quoting details if needed.
Varien_Db_Adapter_Pdo_Mysql