Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 24/12/2010, 10h35   #1
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
Par défaut Parse error dans l'affichage

Bonjour,

Quand j'insère ce code dans mon contrôleur alors il me genere cette erreur:

Citation:
Parse error: parse error in C:\wamp\www\Opticien\application\default\controllers\StatisController.php on line 57
et voila le code:

Code :
1
2
3
4
5
6
7
8
9
 $emp=new Vente();
 
 
 
$id_emp=$this->_request->getParam('id');
 
                        $result = $employe->fetchRow('SELECT sum(prix_total) as somme FROM vente WHERE 'id_emp ='.$id_emp);
			$this->view->emp= $result;
                        Zend_Debug::dump($result);
Alors est-ce-que ce code est incorrect?si oui quelqu'un peut le corriger?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 11h05   #2
Membre chevronné
 
Inscription : juin 2004
Messages : 747
Détails du profil
Informations personnelles :
Âge : 28
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations forums :
Inscription : juin 2004
Messages : 747
Points : 741
Points : 741
Code :
1
2
3
$result = $employe->fetchRow('SELECT sum(prix_total) as somme FROM vente WHERE id_emp ='.$id_emp);
			$this->view->emp= $result;
                        Zend_Debug::dump($result);
__________________
  • Mon blog PHP : http://blog.alterphp.com
  • "Peace cannot be kept by force, it can only be achieved by Understanding" -- Albert Einstein
pc.bertineau est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 11h12   #3
Membre régulier
 
Étudiant
Inscription : mars 2007
Messages : 107
Détails du profil
Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mars 2007
Messages : 107
Points : 93
Points : 93
Bonjour,

Le code est incorrect. L'utilisation des quotes simples est abusive dans ce cas.

Code :
1
2
 
$result = $employe->fetchRow('SELECT sum(prix_total) as somme FROM vente WHERE id_emp = "' . $id_emp . '");
Zenklys est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 17h21   #4
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
Et ici ou est l'erreur dans ce code?

Code :
1
2
3
4
5
6
7
8
 $table=new Vente();
                        $id_cli=$this->_request->getParam('id');
 
$result = $table->fetchRow('SELECT vente.*,mesure.*,client.* FROM vente,mesure,client WHERE id_cli =.$id_cli and 
 
vente.categorie_v='monture'  and mesure.id_cli=client.id_cli and client.id_cli=vente.id_cli');
			$this->view->emp= $result;
                        Zend_Debug::dump($result);
Et merci d'avance
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 18h17   #5
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 456
Détails du profil
Informations personnelles :
Nom : Homme Taoufiq Ben
Âge : 25
Localisation : Maroc

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2009
Messages : 456
Points : 639
Points : 639
$result = $table->fetchRow('SELECT vente.*,mesure.*,client.* FROM vente,mesure,client WHERE id_cli = $id_cli and
vente.categorie_v='monture' and mesure.id_cli=client.id_cli and client.id_cli=vente.id_cli');
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 18h18   #6
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 456
Détails du profil
Informations personnelles :
Nom : Homme Taoufiq Ben
Âge : 25
Localisation : Maroc

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2009
Messages : 456
Points : 639
Points : 639
King_soft t'a laissé un point après la variable $id_cli
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 18h19   #7
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 456
Détails du profil
Informations personnelles :
Nom : Homme Taoufiq Ben
Âge : 25
Localisation : Maroc

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2009
Messages : 456
Points : 639
Points : 639
Code :
1
2
3
$result = $table->fetchRow("SELECT vente.*,mesure.*,client.* FROM vente,mesure,client WHERE id_cli =.$id_cli and 
 
vente.categorie_v='monture'  and mesure.id_cli=client.id_cli and client.id_cli=vente.id_cli");
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 20h14   #8
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
Mais aussi ce code s'execute mais il m'affiche rien:
Code :
1
2
3
  $result = $employe->fetchAll("SELECT sum(produit.quantite) as nombre FROM vente,produit WHERE 
 
produit.categorie_p='monture' and vente.id_produit=produit.id_produit and id_emp =.$id_emp");
le script est correct mais le problème st peut être dans les "
avez-vous une idée?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 20h27   #9
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
m4riachi,

J'ai appliqué le code que tu m'a donné mais voila ce qui me donne comme erreur:
Citation:
Parse error: parse error in C:\wamp\www\Opticien\application\default\controllers\ImprimeController.php on line 69
ou est le problème?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 20h52   #10
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 456
Détails du profil
Informations personnelles :
Nom : Homme Taoufiq Ben
Âge : 25
Localisation : Maroc

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2009
Messages : 456
Points : 639
Points : 639
Affiche ton code de la ligne 69
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2010, 21h05   #11
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
pour l'autre qui contient de la ligne 69 je l'ai déja résolu en faisant ça:
Code :
1
2
3
 $result = $employe->fetchAll('SELECT sum(categorie_v) as nombre FROM vente WHERE categorie_v="monture" and  id_emp 
 
='.$id_emp);
mais il me reste ce code dont il me provoque des erreurs et tu m'a donné ça:
Code :
1
2
3
 $result = $table->fetchRow("SELECT vente.*,mesure.*,client.* FROM vente,mesure,client WHERE id_cli =.$id_cli and 
 
vente.categorie_v='monture'  and mesure.id_cli=client.id_cli and client.id_cli=vente.id_cli");
mais voila ce qui me donne dans l'execution:
Citation:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_cli' in where clause is ambiguous' in C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\Opticien\library\Zend\Db\Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\Opticien\library\Zend\Db\Adapter\Abstract.php(468): Zend_Db_Statement->execute(Array) #3 C:\wamp\www\Opticien\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #4 C:\wamp\www\Opticien\library\Zend\Db\Table\Abstract.php(1505): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #5 C:\wamp\www\Opticien\library\Zend\Db\Table\Abstract.php(1367): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #6 C:\wamp\www\Opticien\application\default\controllers\ImprimeController.php(71): Zend_Db_Table_Abstract->fe in C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php on line 234
ou est donc le problème?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2010, 15h55   #12
Membre régulier
 
Étudiant
Inscription : mars 2007
Messages : 107
Détails du profil
Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mars 2007
Messages : 107
Points : 93
Points : 93
C'est un souci de SQL et non de PHP en l’occurrence, ni de Zend au passage.
De plus l'erreur est écrite telle qu'elle dans la trace.

Citation:
Column 'id_cli' in where clause is ambiguous'
Même pour un débutant en anglais, cette erreur me semble compréhensible.
La colonne id_cli dans la clause "where" est ambiguë. C'est à dire que cette colonne peut exister dans plusieurs tables de ta requête et qu'il te faut donc préciser sur quelle table elle se situe.

Ex :
vente.id_cli
client.id_cli
Zenklys est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2010, 16h04   #13
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
Ok mais donc ou je vais préciser ça?dans id_cli =.$id_cli?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/12/2010, 15h45   #14
Membre régulier
 
Étudiant
Inscription : mars 2007
Messages : 107
Détails du profil
Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mars 2007
Messages : 107
Points : 93
Points : 93
Citation:
Envoyé par king_soft Voir le message
Ok mais donc ou je vais préciser ça?dans id_cli =.$id_cli?
Oui, tout à fait.

Citation:
$result = $employe->fetchAll(
'SELECT
vente.*,mesure.*,client.*
FROM vente,mesure,client
WHERE
id_cli =.$id_cli and
vente.categorie_v='monture' and
mesure.id_cli=client.id_cli and
client.id_cli=vente.id_cli"
Zenklys est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 11h09.


 
 
 
 
Partenaires

Hébergement Web