Problème PHP et requête SQL

Résolu/Fermé
Magyc41 Messages postés 56 Date d'inscription dimanche 17 février 2013 Statut Membre Dernière intervention 9 décembre 2015 - 17 févr. 2013 à 23:07
Magyc41 Messages postés 56 Date d'inscription dimanche 17 février 2013 Statut Membre Dernière intervention 9 décembre 2015 - 18 févr. 2013 à 09:54
Bonjour,

Je suis débutant et je tâtonne! Je précise pour commencer ^^!
Je travaille sous wamp et j'ai réussi a connecter ma page a ma BDD.

Mon problème c'est quand j'essaye d'implanter une requête SQL dans ma page. J'ai des erreurs lors de son exécution et de l'affichage de son résultat.

Voilà mon code.

        <?php
        // Question 1 
        $resultat=$connexion->query("SELECT client.CLI_NOM as client, CLI_ADD, DATE_LIV, DATE_COM, FOUR_NOM, (PRIX*QTE_VENTE) as PRIX
        	FROM client join commande on 'client.CLI_NOM' = 'commande.CLI_NOM' join ligne_commande 
        	on 'commande.ID_LIGNE_CMD' = 'ligne_commande.ID_LIGNE_CMD' JOIN stock on 'ligne_commande.ID_STOCK' = 'stock.ID_STOCK'
			Where ID_CLIENT = '1' ");
        $lignes=$resultat->fetch(PDO::FETCH_OBJ);

        echo "Client : "; echo $lignes->client.'<br />';
        echo "Adresse de Livraison : ";  echo $lignes->CLI_ADD. '<br />'; 
        echo "Fournisseur : "; echo $lignes->DATE_LIV. '<br />'; 
        echo "Prix : "; echo $lignes->DATE_COM. '<br />'; 
        echo "Date_de_Livraison: "; echo $lignes->FOUR_NOM. '<br />'; 
        echo "Date_de_la_commande : "; echo $lignes->PRIX. '<br />'; 

        ?>


Les erreurs :

Client :
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 66
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0

Adresse de Livraison :
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 67
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0

Fournisseur :
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 68
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0

Prix :
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 69
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0

Date_de_Livraison:
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 70
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0

Date_de_la_commande :
( ! ) Notice: Trying to get property of non-object in D:\Magyc\programme\wamp\www\Projet\index.php on line 71
Call Stack
# Time Memory Function Location
1 0.0004 682912 {main}( ) ..\index.php:0



A voir également:

2 réponses

maka54 Messages postés 699 Date d'inscription mercredi 8 avril 2009 Statut Membre Dernière intervention 4 décembre 2016 80
18 févr. 2013 à 09:19
SELECT client.CLI_NOM as client, CLI_ADD, DATE_LIV, DATE_COM, FOUR_NOM, (PRIX*QTE_VENTE) as PRIX
FROM client
JOIN commande on `client`.`CLI_NOM` = `commande`.`CLI_NOM`
JOIN ligne_commande on `commande`.`ID_LIGNE_CMD` = `ligne_commande`.`ID_LIGNE_CMD`
JOIN stock on `ligne_commande`.`ID_STOCK` = `stock`.`ID_STOCK`
Where ID_CLIENT = '1'


Bonjour ton erreur est au niveau de tes jointures
`commande.CLI_NOM` , tu met entre quotes l'ensemble table.champ , c'est faux

soit tu ne met aucune quote soit tu les met sur la table ET le champ comme ceci :

`commande`.`CLI_NOM`

ps : la quote en question est Alt Gr + 7
0
Magyc41 Messages postés 56 Date d'inscription dimanche 17 février 2013 Statut Membre Dernière intervention 9 décembre 2015
18 févr. 2013 à 09:54
Rho toi je t'aime !

Merci beaucoup, s'était ça et sa marche nickel !
0