Probleme de caracteres speciaux sous mysql
Résolu
pierrot81
-
ifisch Messages postés 188 Date d'inscription Statut Membre Dernière intervention -
ifisch Messages postés 188 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai une base de données sous mysql et lorsque je rentre une entrée avec un accent
ou une apostrophe l'enregistrement insere des caractères genre @/? à la place comment encoder correctement ces données ?
Merci bcp
J'ai une base de données sous mysql et lorsque je rentre une entrée avec un accent
ou une apostrophe l'enregistrement insere des caractères genre @/? à la place comment encoder correctement ces données ?
Merci bcp
A voir également:
- Probleme de caracteres speciaux sous mysql
- Caractère spéciaux - Guide
- Caractères spéciaux - Guide
- Caractères spéciaux mac - Guide
- Caractères ascii - Guide
- Raccourcis clavier word caractères spéciaux pdf - Guide
4 réponses
Voici le code php que j'utilise :
function connexion()
{
$host="localhost";
$user="root";
$password="";
$bdd="albicommerces";
$conn=mysql_connect ($host,$user,$password) or die ("erreur de connexion au serveur");
mysql_select_db ($bdd) or die ("erreur d'accés à la base de donnée $bdd");
}
connexion();
mysql_query ("SET CHARACTER SET utf8");
$prenom = htmlentities($_POST['prenom'], ENT_QUOTES);
$nom = htmlentities($_POST['nom'], ENT_QUOTES);
$adresse = htmlentities($_POST['adresse'], ENT_QUOTES);
$cp = htmlentities($_POST['cp'], ENT_QUOTES);
$ville = htmlentities($_POST['ville'], ENT_QUOTES);
$telephone = htmlentities($_POST['telephone'], ENT_QUOTES);
$email = htmlentities($_POST['email'], ENT_QUOTES);
$login = htmlentities($_POST['login'], ENT_QUOTES);
$mdp = htmlentities($_POST['password'], ENT_QUOTES);
$type = htmlentities($_POST['type'], ENT_QUOTES);
$query="INSERT INTO client (nom, prenom, adresse, cp, ville, telephone, email, login, password, type_commerce) VALUES ('$nom', '$prenom', '$adresse', '$cp', '$ville', '$telephone', '$email', '$login', '$mdp', '$type')";
$result=mysql_query($query) or die (mysql_error());
function connexion()
{
$host="localhost";
$user="root";
$password="";
$bdd="albicommerces";
$conn=mysql_connect ($host,$user,$password) or die ("erreur de connexion au serveur");
mysql_select_db ($bdd) or die ("erreur d'accés à la base de donnée $bdd");
}
connexion();
mysql_query ("SET CHARACTER SET utf8");
$prenom = htmlentities($_POST['prenom'], ENT_QUOTES);
$nom = htmlentities($_POST['nom'], ENT_QUOTES);
$adresse = htmlentities($_POST['adresse'], ENT_QUOTES);
$cp = htmlentities($_POST['cp'], ENT_QUOTES);
$ville = htmlentities($_POST['ville'], ENT_QUOTES);
$telephone = htmlentities($_POST['telephone'], ENT_QUOTES);
$email = htmlentities($_POST['email'], ENT_QUOTES);
$login = htmlentities($_POST['login'], ENT_QUOTES);
$mdp = htmlentities($_POST['password'], ENT_QUOTES);
$type = htmlentities($_POST['type'], ENT_QUOTES);
$query="INSERT INTO client (nom, prenom, adresse, cp, ville, telephone, email, login, password, type_commerce) VALUES ('$nom', '$prenom', '$adresse', '$cp', '$ville', '$telephone', '$email', '$login', '$mdp', '$type')";
$result=mysql_query($query) or die (mysql_error());
De souvenirs, lorsque tu créé tes tables SQL (via phpmyadmin c'est super simple), tu peux définir l'encodage des caractères. Et il me semble qu'il faut mettre latin1. JE n'en suis pas sur dit m'en des nouvelles :)