I'm using php and mysqli and I meet a problem with an insert query which looks like :
SET NAMES 'utf8'
$text = mysqli_real_escape_string($connection, $text)
insert into table values('', '".$text."');
Pages are encoded utf8 without BOM and mysql is utf8 general ci
The problem is when I use phpmyadmin the request works fine but when I use website interface and type a text with character "+" it replace with a space " " in mysql but all other characters like ', ", accents, \, /, % are correctly inserted... It worked before I probably made a mistake.
Thanks you by advance and sorry for my poor english.
It is neither mysql, not mysqli, not PHP. None of them put any special meaning in this character.
If you care to verify your inserts, by simply echoing $text
out before insert, you will see that it is already stripped of + sign. So, you have to find the code that strips that symbol out.
A program is not a "black box" which you feed with data and it returns some unexpected output.
But rather set of operators, each performing some data manipulations.
So, you have to debug your code, means you have to echo your $text variable out in various parts of your code to see where it gets changed. Most likely it is getting some unnecessary treatment. After finding that code you may either remove it or ask here if it ok or not.
The only possible case of automated replacement of + character would be if you type your text right in the browser's address bar. In this case + can be replaced with space automatically as PHP does decode urlencoded text and + is used to substitute space character in the URL