fer0an Posted July 25, 2010 Share Posted July 25, 2010 I want using this code to escape ' . can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/ Share on other sites More sharing options...
Mchl Posted July 25, 2010 Share Posted July 25, 2010 What problems are you having? Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090874 Share on other sites More sharing options...
fer0an Posted July 25, 2010 Author Share Posted July 25, 2010 I use this function code to replace ' ,... from my text to add it on mysql db. function escape($text) { $search=array("\\","\0","\n","\r","\x1a","'",'"'); $replace=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); return str_replace($search,$replace,$text); } but I recived an error : atal error: Cannot redeclare escape() (previously declared in /home/... Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090878 Share on other sites More sharing options...
Mchl Posted July 25, 2010 Share Posted July 25, 2010 How is that problem with mysql_real_escape_string(), and why do you want to use this function, while mysql_real_escape_string() is more versatile? Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090883 Share on other sites More sharing options...
fer0an Posted July 25, 2010 Author Share Posted July 25, 2010 I want add some text to my db that have ' same as "Unitá del 25 Luglio 2010". But I recived an error below: Error: exist You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Unitá del 25 Luglio 2010'' at line 1. how I can resolve this problem? Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090886 Share on other sites More sharing options...
Mchl Posted July 25, 2010 Share Posted July 25, 2010 Yes, you should use mysql_real_escape_string function to escape it BEFORE putting it into your query. Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090894 Share on other sites More sharing options...
fer0an Posted July 25, 2010 Author Share Posted July 25, 2010 can you write correct code for me ? I added $text to my db. Is this is correct? $text = mysql_real_escape_string('); Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090895 Share on other sites More sharing options...
trq Posted July 25, 2010 Share Posted July 25, 2010 Read the examples in the manual. Its not rocket science. Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1090896 Share on other sites More sharing options...
Zagga Posted July 25, 2010 Share Posted July 25, 2010 but I recived an error : atal error: Cannot redeclare escape() (previously declared in /home/...You are getting this error because you already have a function called "escape". Zagga Quote Link to comment https://forums.phpfreaks.com/topic/208831-mysql_real_escape_string/#findComment-1091036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.