guestabc Posted December 3, 2008 Share Posted December 3, 2008 Hi i'm trying to insert into my access database a comment from the user. Although this works fine i have discovered that special character brings out a error such as if the user types a ' how do i get around this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/ Share on other sites More sharing options...
gevans Posted December 3, 2008 Share Posted December 3, 2008 mysql_real_escape_string() so $foo = mysql_real_escape_string($_POST['name_from_form']) Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-705554 Share on other sites More sharing options...
guestabc Posted December 4, 2008 Author Share Posted December 4, 2008 thanks not able to try now as my host is down argh!!!! just something i noticed. will give it a try in the morning thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-705565 Share on other sites More sharing options...
gevans Posted December 4, 2008 Share Posted December 4, 2008 You should try installing php and Apache locally with something like xampp, then you can develop all you want!! Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-705572 Share on other sites More sharing options...
guestabc Posted December 4, 2008 Author Share Posted December 4, 2008 yer i have it installed though only had my files on the online server. But i have them backed up now. I've tried the mysql_real_escape_string() however i get a connection error, I guess its because i'm using Access (don't ask why, its a requirement for the project). Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-706025 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 yer i have it installed though only had my files on the online server. But i have them backed up now. I've tried the mysql_real_escape_string() however i get a connection error, I guess its because i'm using Access (don't ask why, its a requirement for the project). As long as you have a mysql db setup, you just have to make a connection to that DB and do not necessarily have to use that db. But if you do some googling you can find functions that "simulate" the mysql_real_escape_string in fact you may be able to find it in the comments on the page. However it simulates it, it is not it. So yea. Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-706028 Share on other sites More sharing options...
guestabc Posted December 4, 2008 Author Share Posted December 4, 2008 yer i have it installed though only had my files on the online server. But i have them backed up now. I've tried the mysql_real_escape_string() however i get a connection error, I guess its because i'm using Access (don't ask why, its a requirement for the project). As long as you have a mysql db setup, you just have to make a connection to that DB and do not necessarily have to use that db. But if you do some googling you can find functions that "simulate" the mysql_real_escape_string in fact you may be able to find it in the comments on the page. However it simulates it, it is not it. So yea. so i have to setup a MYSQL database along as my Microsoft Access database? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-706290 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 There are a few different alternative options to it: http://www.google.com/search?hl=en&q=mysql_real_Escape_string+alternative&btnG=Google+Search&aq=f&oq= The best example that I used to use is: function my_real_escape_string($value) { $search = array("\x00", "\n", "\r", "\\", "'", "\"", "\x1a"); $replace = array("\\x00", "\\n", "\\r", "\\\\" ,"\'", "\\\"", "\\\x1a"); return str_replace($search, $replace, $value); } Quote Link to comment https://forums.phpfreaks.com/topic/135440-insert/#findComment-706297 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.