Syntax error, unexcepted t_variable
allansag
Messages postés
8
Date d'inscription
Statut
Membre
-
allansag Messages postés 8 Date d'inscription Statut Membre -
allansag Messages postés 8 Date d'inscription Statut Membre -
Bonjour,
Aidez moi, j'arrive pas a voir l'erreur dans mon code. Et pourtant j'ai fait attention au point virgule et autrs. Neanmoins je vous envie mon code.
$connexion= mysql_connect("localhost","root","sagousag");
if(!$connexion)
{
$msg =urlencode("Connexion echoué, pbm avec la base");
header("Location: http://virtual2.com/form_creation.php?msg=$msg");
exit;
}
mysql_select_db("exemple2",$connexion);
$mysql_result =mysql_query("SELECT login FROM utilisateurs;");
while($ligne = mysql_fetch_array($mysql_result))
{
if($login == $ligne["login"])
{
mysql_close($connexion);
$msg =urlencode("Désolé, ce login a deja été pris");
header ("Location: http://virtual2.com/form_creation.php?msg=$msg");
exit;
}
}
$requete ="INSERT INTO utilisateurs (login,passwd,prenom,adresse,fixe,portable)"."VALUES ("$login","$password","$nom","$prenom","$adresse","$fixe","$portable")";
$mysql_result = mysql_query("$requete");
mysql_close($connexion);
if($mysql_result)
{
$msg =urlencode("Le compte $login a été creer");
header ("Location: http://virtual2.com/index.php?msg=$msg");
exit;
}
else
L'erreur est declare a la ligne $requete ="INSERT INTO utilisateurs (login,passwd,prenom,adresse,fixe,portable)"."VALUES ("$login","$password","$nom","$prenom","$adresse","$fixe","$portable")";
Aidez moi, j'arrive pas a voir l'erreur dans mon code. Et pourtant j'ai fait attention au point virgule et autrs. Neanmoins je vous envie mon code.
$connexion= mysql_connect("localhost","root","sagousag");
if(!$connexion)
{
$msg =urlencode("Connexion echoué, pbm avec la base");
header("Location: http://virtual2.com/form_creation.php?msg=$msg");
exit;
}
mysql_select_db("exemple2",$connexion);
$mysql_result =mysql_query("SELECT login FROM utilisateurs;");
while($ligne = mysql_fetch_array($mysql_result))
{
if($login == $ligne["login"])
{
mysql_close($connexion);
$msg =urlencode("Désolé, ce login a deja été pris");
header ("Location: http://virtual2.com/form_creation.php?msg=$msg");
exit;
}
}
$requete ="INSERT INTO utilisateurs (login,passwd,prenom,adresse,fixe,portable)"."VALUES ("$login","$password","$nom","$prenom","$adresse","$fixe","$portable")";
$mysql_result = mysql_query("$requete");
mysql_close($connexion);
if($mysql_result)
{
$msg =urlencode("Le compte $login a été creer");
header ("Location: http://virtual2.com/index.php?msg=$msg");
exit;
}
else
L'erreur est declare a la ligne $requete ="INSERT INTO utilisateurs (login,passwd,prenom,adresse,fixe,portable)"."VALUES ("$login","$password","$nom","$prenom","$adresse","$fixe","$portable")";
Configuration: Linux Firefox 3.0.3
5 réponses
-
$requete ="INSERT INTO utilisateurs (login,passwd,prenom,adresse,fixe,portable)"."VALUES ('$login','$password','$nom','$prenom','$adresse','$fixe','$portable')";
-
-
Il est probable que parmi les valeurs de : $login','$password','$nom','$prenom','$adresse','$fixe','$portable
L'une ne permette pas l'ajout en base de données correctement.
T'en dire plus devient difficile sans la structure de la table et le contenu de ces variables.-
voici la structure de la table:
CREATE TABLE utilisateurs (
id int(6) NOT NULL auto_increment,
login varchar(20) NOT NULL,
passwd varchar(40) NOT NULL,
nom varchar(40),
prenom varchar(40),
adresse varchar(255),
fixe varchar(20),
portable varchar(20),
KEY id(id)
)
;
Et le code html:
<html>
<head>
<title>Creation d'un compte</title>
</head>
<body>
<div align="center">
<h1>Creation d'un compte</h1>
<i>Les champs avec un <font color ="red">*</font> sont obligatoires</i>
<br />
</div>
<br />
<form action ="./creation.php" method ="post">
<div align="center">
<table width="600" border="1">
<tr>
<td>
<table width="100" border="0">
<tr>
<td>Login <font color="red">*</font>: </td>
<td><input type="text" name ="login" size="20" maxlength="20"></td>
</tr>
<tr>
<td>Mot de passe <font color="red">*</font>: </td>
<td><input type="password" name ="password" size="20" maxlength="40"></td>
</tr>
<tr>
<td>Verification du mot de passe <font color="red">*</font>: </td>
<td><input type="password" name ="verif" size="20" maxlength="20"></td>
</tr>
<tr>
<td>Nom:</td>
<td><input type="text" name ="nom" size="20" maxlength="20"></td>
</tr>
<tr>
<td>Prenom: </td>
<td><input type="text" name ="prenom" size="20" maxlength="20"></td>
</tr>
<tr>
<td>Adresse:</td>
<td><input type="text" name ="adresse" size="40" maxlength="255"></td>
</tr>
<tr>
<td>Telephone fixe: </td>
<td><input type="text" name ="fixe" size="20" maxlength="20"></td>
</tr>
<tr>
<td>Telephone portable:</td>
<td><input type="text" name ="portable" size="20" maxlength="20"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type ="submit" value ="Creation du compte">
</td>
</tr>
</table>
</td>
</tr>
</div>
</form>
</body>
</html>
-
-
Bonjour
Tu n'aurais pas oublié un champ ?
$requete ="INSERT INTO utilisateurs (login,passwd,nom,prenom,adresse,fixe,portable)"."VALUES ('$login','$password','$nom','$prenom','$adresse','$fixe','$portable')"; -
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
Effectivement,
avec l'ajout de ce champ (nom) ca marche il etait prevu
Merci a vous tous.