twison Posted April 4, 2021 Share Posted April 4, 2021 I'm having an issue with my chat where chat posts are not getting inserted when using words like don't or won't. mysql_query("INSERT INTO chat (poster_id,date,class,poster_name,message,whisper) VALUES ('".$menu['id']."','$date','$class','$name','$message','$whisper_id')"); $message is the text part of the insert. I've tried "$message", "'.$message.'", and '".$message."' none of it helps. One of them simply changed the issue from ' to " not getting inserted. Any advice would be great. I'm a bit rusty on my coding skills as I haven't done it it awhile. Quote Link to comment Share on other sites More sharing options...
Sim Posted April 4, 2021 Share Posted April 4, 2021 mysql_real_escape_string($message) Or htmlentities($message) I cant remember which is correct, been so long since i had to use those fumctions. Change your database encoding to UTF-8 should help(i could be wrong). 1 Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted April 4, 2021 Share Posted April 4, 2021 @Sim is correct; you need to escape your string variables with mysql_real_escape_string(). $name = mysql_real_escape_string($name); $message = mysql_real_escape_string($message); // escape more strings if needed mysql_query(...); 2 Quote Link to comment Share on other sites More sharing options...
Sim Posted April 4, 2021 Share Posted April 4, 2021 I was thinking about tagging you @Magictallguy 1 Quote Link to comment Share on other sites More sharing options...
twison Posted April 7, 2021 Author Share Posted April 7, 2021 Thanks guys that is exactly what was needed, thank you!!! Quote Link to comment 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.