Help! bugs en php...
Fermé
Lcf.vs
Messages postés
144
Date d'inscription
vendredi 13 octobre 2006
Statut
Membre
Dernière intervention
10 avril 2010
-
12 oct. 2007 à 07:33
Reivax962 Messages postés 3672 Date d'inscription jeudi 16 juin 2005 Statut Membre Dernière intervention 11 février 2021 - 12 oct. 2007 à 14:45
Reivax962 Messages postés 3672 Date d'inscription jeudi 16 juin 2005 Statut Membre Dernière intervention 11 février 2021 - 12 oct. 2007 à 14:45
A voir également:
- Help! bugs en php...
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour à la ligne php ✓ - Forum PHP
- Php?id=1 - Forum PHP
- Retour a la ligne avec Echo comment faire ? - Forum Webmastering
5 réponses
Faudrait préciser un peut plus qu'est ce qui bug parce que là le code est dégueulasse si en plus faut chercher.
"Ce qui se conçoit bien s''énonce clairement"
"Ce qui se conçoit bien s''énonce clairement"
Lcf.vs
Messages postés
144
Date d'inscription
vendredi 13 octobre 2006
Statut
Membre
Dernière intervention
10 avril 2010
36
12 oct. 2007 à 14:15
12 oct. 2007 à 14:15
bonjour Hotrod,
dans un premier temps, j'ai ceci:
Parse error: syntax error, unexpected T_ELSE in /home/emarketstudy2/www/index.php on line 39
mais il est possible que j'aie d'autres erreurs...
en quoi mon bug est-il dégueulasse?
dsl, suis noob en php, alors si on pouvait m'expliquer en quoi je fais qqch qui ne va pas, ce serait sympa.
merci
dans un premier temps, j'ai ceci:
Parse error: syntax error, unexpected T_ELSE in /home/emarketstudy2/www/index.php on line 39
mais il est possible que j'aie d'autres erreurs...
en quoi mon bug est-il dégueulasse?
dsl, suis noob en php, alors si on pouvait m'expliquer en quoi je fais qqch qui ne va pas, ce serait sympa.
merci
Lcf.vs
Messages postés
144
Date d'inscription
vendredi 13 octobre 2006
Statut
Membre
Dernière intervention
10 avril 2010
36
12 oct. 2007 à 14:30
12 oct. 2007 à 14:30
oh, me suis rendu compte d'une erreur de copier-coller, la voilà rectifiée mais ça ne change rien à mon problème apparement, la lignefautive est le
else (ligne 39)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bienvenue</title>
</head>
<style type="text/css">
form
{
text-align:center;
}
</style>
<body>
<?php
if ($_POST['RegistClient'] != NULL AND $_POST['KPClient'] != NULL) // Si on a quelque chose à enregistrer
{
if ($RegistClient = $_POST['RegistClient']AND$KPClient = $_POST['KPClient'])
{
mysql_connect("sql5.power-heberg.net", "emarketstudy2", "dyy6k47z");
mysql_select_db("emarketstudy2");
$RegistClient = mysql_real_escape_string(htmlspecialchars($_POST['RegistClient']));
$KPClient = mysql_real_escape_string(htmlspecialchars($_POST['KPClient']));
mysql_close();
?>
<!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"> xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GoTox.php</title>
<?php
header("Location: https://www.google.be/?gws_rd=ssl");
?>
</head>
<body>
</body>
</html>
}
<?php
else
{
?>
<!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"> xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inscription</title>
</head>
<style type="text/css">
form
{
text-align:center;
}
</style>
<body>
<?php
if ($_POST['RegistClient'] != NULL AND $_POST['KPClient'] != NULL AND $_POST['NomClient'] != NULL AND $_POST['PrenomClient'] != NULL AND $_POST['CodePostalClient'] != NULL AND $_POST['$VilleClient'] != NULL AND $_POST['PaysClient'] != NULL AND $_POST['TelephoneClient'] != NULL AND $_POST['E-mailClient'] != NULL AND $_POST['SiteClient'] != NULL AND $_POST['TypeClient'] != NULL)
{
mysql_connect("sql5.power-heberg.net", "emarketstudy2", "dyy6k47z");
mysql_select_db("emarketstudy2");
$RegistClient = mysql_real_escape_string(htmlspecialchars($_POST['RegistClient']));
$KPClient = mysql_real_escape_string(htmlspecialchars($_POST['KPClient']));
$NomClient = mysql_real_escape_string(htmlspecialchars($_POST['NomClient']));
$PrenomClient = mysql_real_escape_string(htmlspecialchars($_POST['PrenomClient']));
$CodePostalClient = mysql_real_escape_string(htmlspecialchars($_POST['CodePostalClient']));
$VilleClient = mysql_real_escape_string(htmlspecialchars($_POST['VilleClient']));
$PaysClient = mysql_real_escape_string(htmlspecialchars($_POST['PaysClient']));
$TelephoneClient = mysql_real_escape_string(htmlspecialchars($_POST['TelephoneClient']));
$E-mailClient = mysql_real_escape_string(htmlspecialchars($_POST['E-mailClient']));
$SiteClient = mysql_real_escape_string(htmlspecialchars($_POST['SiteClient']));
$TypeClient = mysql_real_escape_string(htmlspecialchars($_POST['TypeClient']));
mysql_query("INSERT INTO Clients VALUES('', '$NomClient', '$PrenomClient', '$CodePostalClient', '$VilleClient', '$PaysClient', '$TelephoneClient', '$E-mailClient', '$SiteClient', '$TypeClient', '$RegistClient')");
mysql_query("INSERT INTO KPClients VALUES('', "RegistClient', '$KPClient')");
mysql_close();
}
}
</body>
</html>
merci à ceux qui prendront la peine de m'expiquer
else (ligne 39)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bienvenue</title>
</head>
<style type="text/css">
form
{
text-align:center;
}
</style>
<body>
<?php
if ($_POST['RegistClient'] != NULL AND $_POST['KPClient'] != NULL) // Si on a quelque chose à enregistrer
{
if ($RegistClient = $_POST['RegistClient']AND$KPClient = $_POST['KPClient'])
{
mysql_connect("sql5.power-heberg.net", "emarketstudy2", "dyy6k47z");
mysql_select_db("emarketstudy2");
$RegistClient = mysql_real_escape_string(htmlspecialchars($_POST['RegistClient']));
$KPClient = mysql_real_escape_string(htmlspecialchars($_POST['KPClient']));
mysql_close();
?>
<!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"> xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GoTox.php</title>
<?php
header("Location: https://www.google.be/?gws_rd=ssl");
?>
</head>
<body>
</body>
</html>
}
<?php
else
{
?>
<!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"> xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inscription</title>
</head>
<style type="text/css">
form
{
text-align:center;
}
</style>
<body>
<?php
if ($_POST['RegistClient'] != NULL AND $_POST['KPClient'] != NULL AND $_POST['NomClient'] != NULL AND $_POST['PrenomClient'] != NULL AND $_POST['CodePostalClient'] != NULL AND $_POST['$VilleClient'] != NULL AND $_POST['PaysClient'] != NULL AND $_POST['TelephoneClient'] != NULL AND $_POST['E-mailClient'] != NULL AND $_POST['SiteClient'] != NULL AND $_POST['TypeClient'] != NULL)
{
mysql_connect("sql5.power-heberg.net", "emarketstudy2", "dyy6k47z");
mysql_select_db("emarketstudy2");
$RegistClient = mysql_real_escape_string(htmlspecialchars($_POST['RegistClient']));
$KPClient = mysql_real_escape_string(htmlspecialchars($_POST['KPClient']));
$NomClient = mysql_real_escape_string(htmlspecialchars($_POST['NomClient']));
$PrenomClient = mysql_real_escape_string(htmlspecialchars($_POST['PrenomClient']));
$CodePostalClient = mysql_real_escape_string(htmlspecialchars($_POST['CodePostalClient']));
$VilleClient = mysql_real_escape_string(htmlspecialchars($_POST['VilleClient']));
$PaysClient = mysql_real_escape_string(htmlspecialchars($_POST['PaysClient']));
$TelephoneClient = mysql_real_escape_string(htmlspecialchars($_POST['TelephoneClient']));
$E-mailClient = mysql_real_escape_string(htmlspecialchars($_POST['E-mailClient']));
$SiteClient = mysql_real_escape_string(htmlspecialchars($_POST['SiteClient']));
$TypeClient = mysql_real_escape_string(htmlspecialchars($_POST['TypeClient']));
mysql_query("INSERT INTO Clients VALUES('', '$NomClient', '$PrenomClient', '$CodePostalClient', '$VilleClient', '$PaysClient', '$TelephoneClient', '$E-mailClient', '$SiteClient', '$TypeClient', '$RegistClient')");
mysql_query("INSERT INTO KPClients VALUES('', "RegistClient', '$KPClient')");
mysql_close();
}
}
</body>
</html>
merci à ceux qui prendront la peine de m'expiquer
Reivax962
Messages postés
3672
Date d'inscription
jeudi 16 juin 2005
Statut
Membre
Dernière intervention
11 février 2021
1 011
12 oct. 2007 à 14:37
12 oct. 2007 à 14:37
Bonjour,
Utilise les balises < code> et </code> autour de ton code, sinon c'est illisible.
Ensuite, une page xhtml ne contient qu'un seul doctype, qu'une seule balise html, qu'un seul head ce qui n'est pas le cas ici.
Troisièmement, tu utilises des variables qui ne sont pas déclarées ni affectées : $RegistClient par exemple.
Quatrièmement, tu as collé un AND aux deux opérandes sur ta troisième ligne de code php.
Cinquièmement, tu fermes ton accolade } avant de revenir dans une section de code php, elle est donc prise pour de l'html et ne ferme pas ton IF : d'où l'erreur qui fait que ton else n'est pas accepté.
C'est en tout ça que ton code est dégueulasse ;)
Xavier
Utilise les balises < code> et </code> autour de ton code, sinon c'est illisible.
Ensuite, une page xhtml ne contient qu'un seul doctype, qu'une seule balise html, qu'un seul head ce qui n'est pas le cas ici.
Troisièmement, tu utilises des variables qui ne sont pas déclarées ni affectées : $RegistClient par exemple.
Quatrièmement, tu as collé un AND aux deux opérandes sur ta troisième ligne de code php.
Cinquièmement, tu fermes ton accolade } avant de revenir dans une section de code php, elle est donc prise pour de l'html et ne ferme pas ton IF : d'où l'erreur qui fait que ton else n'est pas accepté.
C'est en tout ça que ton code est dégueulasse ;)
Xavier
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Reivax962
Messages postés
3672
Date d'inscription
jeudi 16 juin 2005
Statut
Membre
Dernière intervention
11 février 2021
1 011
12 oct. 2007 à 14:45
12 oct. 2007 à 14:45
Ah, et j'ai oublié : un test dégalité ne se fait pas avec = mais avec ==
Car = est un symbole d'affectation et non pas un comparateur.
Car = est un symbole d'affectation et non pas un comparateur.