[PHP/MYSQL] Parse error: parse error, unexpec
Résolu/Fermé
bichou92
Messages postés
14
Date d'inscription
mercredi 25 juin 2008
Statut
Membre
Dernière intervention
30 juin 2008
-
25 juin 2008 à 15:42
bichou92 Messages postés 14 Date d'inscription mercredi 25 juin 2008 Statut Membre Dernière intervention 30 juin 2008 - 25 juin 2008 à 16:21
bichou92 Messages postés 14 Date d'inscription mercredi 25 juin 2008 Statut Membre Dernière intervention 30 juin 2008 - 25 juin 2008 à 16:21
A voir également:
- [PHP/MYSQL] Parse error: parse error, unexpec
- Easy php - Télécharger - Divers Web & Internet
- Mysql community server - Télécharger - Bases de données
- Eespt technical error ✓ - Forum TNT / Satellite / Réception
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Error 2002 (hy000): can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (2) ✓ - Forum Linux / Unix
2 réponses
bichou92
Messages postés
14
Date d'inscription
mercredi 25 juin 2008
Statut
Membre
Dernière intervention
30 juin 2008
2
25 juin 2008 à 16:21
25 juin 2008 à 16:21
MERCI Julien pour ton aide
Le problème vient du fait que l'on ne peut place une variable globale dans du SQL (une variable du type $_POST[""] par exemple). Il faut donc créer une variable locale qui a pour valeur la-dite variable globale.
Voici le code corrigé de ent2.php :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<?php
$_POST["COD_POST_VILLE"];
$liendb = mysql_connect("*******","*******","*******");
mysql_select_db("lionell_keepass");
$sql = 'SELECT * FROM VILLE';
$ville = mysql_query($sql);
while($row=mysql_fetch_row($ville)){
if($row[2]==$_POST["COD_POST_VILLE"]){
$villenew=false;
break;
}else{
$villenew=true;
}
}
if($villenew==true){
$nom_ville = $_POST["NOM_VILLE"];
$cod_post_ville = $_POST["COD_POST_VILLE"];
$sql="INSERT INTO VILLE (NOM_VILLE, COD_POST_VILLE) VALUES ('$nom_ville','$cod_post_ville')";
echo "ville crée";
}else{
echo "existe deja";
}
mysql_close($liendb);
?>
</body>
</html>
Voici le code corrigé de ent2.php :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<?php
$_POST["COD_POST_VILLE"];
$liendb = mysql_connect("*******","*******","*******");
mysql_select_db("lionell_keepass");
$sql = 'SELECT * FROM VILLE';
$ville = mysql_query($sql);
while($row=mysql_fetch_row($ville)){
if($row[2]==$_POST["COD_POST_VILLE"]){
$villenew=false;
break;
}else{
$villenew=true;
}
}
if($villenew==true){
$nom_ville = $_POST["NOM_VILLE"];
$cod_post_ville = $_POST["COD_POST_VILLE"];
$sql="INSERT INTO VILLE (NOM_VILLE, COD_POST_VILLE) VALUES ('$nom_ville','$cod_post_ville')";
echo "ville crée";
}else{
echo "existe deja";
}
mysql_close($liendb);
?>
</body>
</html>