I'm trying to insert some names with special characters, such as an apostrophe, into a mysql database using php. For example:
INSERT INTO PLAYERS VALUES('{$players[$n][1]}','$nom_team');
where $players
is an array that contains names as N'Zogbia
, N'Diaye
, etc. However, this results in an error.
I have tried using the addslashes function:
$players[$n][1] = addslashes( $players[$n][1] );
but this doesn't work correctly. What gets saved in the database is N\'Zogbia
, or sometimes N\\\\\\\\\\'Diaye
.
I have run out of ideas to fix the problem. I hope you guys can help me.