I'm trying to enter some texte in my database, text wh'os entered by users. However I'm having an issue with some special characters, namely "&" and "+".
When the text involves a &, the sentence is chopped and nothing after that character will be added in the db. For the +, it makes the whole entry null.
I don't get it, becaue I'm escaping the special characters with mysqli_real_escape_string
Here's the query:
$texte=mysqli_real_escape_string($texte);
$bdd->query('INSERT INTO messages (idconversation, texte, id_emeteur, id_recepteur, invitation) VALUES ('.$idConversation.', \''.$texte.'\',\''.$idEmeteur.'\',\''.$idDestinatere.'\',\''.$invite.'\')');
Any idea? :/
EDIT! (first, all the data that's inserted in the databae is served generated and not coming from the user, except the $text variable)
Thakns to your advice, I've investiguated the other steps in the process. It looks like it's got nothing to do with mysql or php. Earlier in the process, the data is transfered using ajax. Here's the code
xhr.open("POST", "index.php?page=repondreMessage", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("message="+nouveaumessage+"&pseudo="+destinataire+"&tickbox="+tickbox);
(th data is here in "message"). How should i process the data so it can safely be conveyed in the request?