salut je suis un tuto sur le net mais je bute sur une jointure de 3 tables . alors si quelqu'un pouvait m'aider .
voici l erreur qui s'affiche :
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\RESO_SOCIAL\functions\conversations.func.php on line 20.
voici la structure de mes tables :
conversations` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`sujet_conversation` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations` (`id_conversation`, `sujet_conversation`) VALUES
(2, 'la joie'),
(3, 'track')
conversations_membres` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`pseudo_dest` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations_membres` (`id_conversation`, `pseudo_dest`) VALUES
(2, 'isabelle'),
(3, 'isabelle'),
conversations_messages` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`pseudo_exp` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`corps_message` text COLLATE utf8_unicode_ci NOT NULL,
`date_message` datetime NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations_messages` (`id_conversation`, `pseudo_exp`, `corps_message`, `date_message`) VALUES
(2, 'msi79', 'je veux te marier', '2012-12-19 21:29:32'),
(3, 'msi79', 'je vais te tracker a mort bb', '2012-12-20 09:01:40'),
utilisteurs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pseudo` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`sexe` varchar(12) COLLATE utf8_unicode_ci NOT NULL,
`situation` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`apropos` text COLLATE utf8_unicode_ci NOT NULL,
`avatar` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
INSERT INTO `utilisteurs` (`id`, `pseudo`, `password`, `email`, `sexe`, `situation`, `apropos`, `avatar`) VALUES
(1, 'msi79', '0a689fa3811f3d605d82943c32cf17cdd764b291', 'soulzana@yahoo.fr', 'Homme', 'C�libataire', 'suis superrrrrrrrrrrrrrr', 'Photo_00058.jpg'),
(2, 'isabelle', '4303f7fbc75763e3133bf7714fc90f02260848b5', 'isa@live.fr', 'Homme', 'C�libataire', 'c mois la plus belle', '20121126_122254.jpg'),
(3, 'sool', '0a689fa3811f3d605d82943c32cf17cdd764b291', 'sool@yahoo.fr', 'Homme', 'C�libataire', 'le plus puissant', 'jolie.jpg');
et voici ma code php
voici l erreur qui s'affiche :
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\RESO_SOCIAL\functions\conversations.func.php on line 20.
voici la structure de mes tables :
conversations` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`sujet_conversation` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations` (`id_conversation`, `sujet_conversation`) VALUES
(2, 'la joie'),
(3, 'track')
conversations_membres` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`pseudo_dest` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations_membres` (`id_conversation`, `pseudo_dest`) VALUES
(2, 'isabelle'),
(3, 'isabelle'),
conversations_messages` (
`id_conversation` int(10) NOT NULL AUTO_INCREMENT,
`pseudo_exp` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`corps_message` text COLLATE utf8_unicode_ci NOT NULL,
`date_message` datetime NOT NULL,
PRIMARY KEY (`id_conversation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
INSERT INTO `conversations_messages` (`id_conversation`, `pseudo_exp`, `corps_message`, `date_message`) VALUES
(2, 'msi79', 'je veux te marier', '2012-12-19 21:29:32'),
(3, 'msi79', 'je vais te tracker a mort bb', '2012-12-20 09:01:40'),
utilisteurs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pseudo` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`sexe` varchar(12) COLLATE utf8_unicode_ci NOT NULL,
`situation` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`apropos` text COLLATE utf8_unicode_ci NOT NULL,
`avatar` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
INSERT INTO `utilisteurs` (`id`, `pseudo`, `password`, `email`, `sexe`, `situation`, `apropos`, `avatar`) VALUES
(1, 'msi79', '0a689fa3811f3d605d82943c32cf17cdd764b291', 'soulzana@yahoo.fr', 'Homme', 'C�libataire', 'suis superrrrrrrrrrrrrrr', 'Photo_00058.jpg'),
(2, 'isabelle', '4303f7fbc75763e3133bf7714fc90f02260848b5', 'isa@live.fr', 'Homme', 'C�libataire', 'c mois la plus belle', '20121126_122254.jpg'),
(3, 'sool', '0a689fa3811f3d605d82943c32cf17cdd764b291', 'sool@yahoo.fr', 'Homme', 'C�libataire', 'le plus puissant', 'jolie.jpg');
et voici ma code php
Code:
<?php
////la function qui va recuperer les conversations
function recup_conversation(){
$results = array();
$sql = mysql_query("
SELECT
conversations.id_conversation,
conversations.sujet_conversation,
utilisteurs.pseudo,
utilisteurs.avatar,
conversations_messages.date_message
FROM conversations
INNER JOIN conversations_messages ON conversations.id_conversation = conversations_messages.id_conversation
INNER JOIN utilisteurs ON utilisteurs.pseudo = conversations_messages.pseudo_exp
GROUP BY conversations.id_conversation
ORDER BY conversations_messages.date_message
");
while($row = mysql_fetch_assoc($sql)){
$results[] = $row;
}
return $results;
}
?>