devmouad
Messages postés27Date d'inscriptionsamedi 26 janvier 2008StatutMembreDernière intervention 6 décembre 2010
-
11 mai 2009 à 23:55
kohntark
Messages postés3705Date d'inscriptionlundi 5 juillet 2004StatutMembreDernière intervention27 avril 2012
-
12 mai 2009 à 19:04
qauand j'exécute le bout de code suivant
if(!isset($_POST['d1']) && !isset($_POST['d2']))
$s=" SELECT * FROM detail_cmd,commande where detail_cmd.id_detail_cmd=commande.id_detail_cmd and commande.code_Client='".$client."' ";
else $s=" SELECT * FROM detail_cmd , commande where detail_cmd.id_detail_cmd=commande.id_detail_cmd and commande.code_Client="'.$client.'" and commande.dateCmd between '$date_d' and '$date_f' ";
$k=mysql_query($s);
PHP m'affiche l'erreur suivante
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\EasyPHP 2.0b1\www\s_gestion_comercial\pages\rapport_client.php dans la ligne de la clause du ELSE
Arto_8000
Messages postés1044Date d'inscriptionlundi 7 mars 2005StatutMembreDernière intervention13 juillet 20107 12 mai 2009 à 04:12
Je crois que c'est à cause de ce que j'ai mis en gras :
if(!isset($_POST['d1']) && !isset($_POST['d2']))
$s= " SELECT
* FROM detail_cmd,commande where
detail_cmd.id_detail_cmd=commande.id_detail_cmd and
commande.code_Client='".$client."' ";
else $s=" SELECT * FROM
detail_cmd , commande where
detail_cmd.id_detail_cmd=commande.id_detail_cmd and
commande.code_Client= "'.$client.'" and commande.dateCmd between
'$date_d' and '$date_f' ";
$k =mysql_query($s);
Sinon tu serais mieux avec une autre syntaxe pour faire ce genre de truc.
$s = (!isset($_POST['d1']) && !isset($_POST['d2'])) ?
"Ta premiere requete si c'est vrai" :
"Ta deuxime requete si c'est faux";
devmouad
Messages postés27Date d'inscriptionsamedi 26 janvier 2008StatutMembreDernière intervention 6 décembre 2010 12 mai 2009 à 17:50
j'ai modifier dans mon code comme l'a dit [auteur/ARTO8000/463723.aspx Arto_8000]
mais maintenant que le bloque if qui marche le bloque else ne marche pas et php ne m'affiche aucun message d'erreur
voici le code en question
if(isset($_POST['d1']) && isset($_POST['d2']))
$s=" SELECT * FROM detail_cmd , commande where detail_cmd.id_detail_cmd=commande.id_detail_cmd and commande.code_Client='".$client."' and commande.dateCmd between '".$date_d."' and '".$date_f."' ";
else
$s=" SELECT * FROM detail_cmd,commande where detail_cmd.id_detail_cmd=commande.id_detail_cmd and commande.code_Client='".$client."' ";
kohntark
Messages postés3705Date d'inscriptionlundi 5 juillet 2004StatutMembreDernière intervention27 avril 201230 12 mai 2009 à 18:15
Salut,
"else ne marche pas"
=>
c'était déjà le cas au début, non ?
Qu'entends tu par "ne marche pas" ? N'est jamais exécuté ? 1 seul résultat retourné ? aucun ?
Cordialement,
Kohntark -
Vous n’avez pas trouvé la réponse que vous recherchez ?
kohntark
Messages postés3705Date d'inscriptionlundi 5 juillet 2004StatutMembreDernière intervention27 avril 201230 12 mai 2009 à 19:04
au début aucun bloque ne marché ni le if ni sont else
=>
normal puisque tu avais une erreur fatale, rien ne pouvait s'exécuter
Il y a des (mal)chances pour que ce soit le between qui pose pb.
Donne le code qui définie $date_d et $date_f et un exemple de la chaine qu'ils doivent contenir ainsi que les caractéristiques du champ dateCmd.
Par ailleurs as tu une gestion d'erreur dans l'exécution de ta requête ?