Warning: mysql_fetch_array(): supplied argume

dudd -  
 Steevy -
Bonjour,

Je développe une function qui envois des email de notification sur mon forum (bbpress)

J'ai cette erreur :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /.../monscript.php on line 17

Mon code :

function notification_reponse() {
global $topic_last_post_link, $topic_id;
$header = 'From: '.bb_get_option('from_email')."\n"; 
$header .= "Content-type: text/html; charset= iso-8859-1\n";
$msg =__('<p>Vous avez reçu une réponse pour votre question posée sur le forum commentguerir.</p><p>Pour lire cette réponse veuillez visiter cette page :</p>').get_topic_last_post_link($topic_id).__('<p>Pour ne plus recevoir de notifications, veuillez répondre à cet email avec comme titre: désinscription</p>');
$msg = utf8_decode($msg);
$niv1= mysql_query("select post_id from bb_posts where topic_id=$topic_id");
while ($donnee1=mysql_fetch_array($niv1)){
$all = mysql_query("select meta_value from bb_meta where meta_key = 'post_email' and object_id = $donnee1[post_id]") ; 
while ($donnee2 = mysql_fetch_array($all)){
$lastpost=mysql_query("select topic_last_post_id from bb_topics where topic_id=$topic_id limit 1");
$lastpost1=mysql_fetch_array($lastpost);
if ($donnee1[post_id]!=$lastpost1[topic_last_post_id]){
bb_mail($donnee2[meta_value], "Une réponse à votre question", $msg, $header);
}
}
}
}


2 réponses

  1. lofawu Messages postés 103 Date d'inscription   Statut Membre Dernière intervention   9
     
    Tu peux aérer ton code pour qu'on y voie un peu mieux... sinon pour plus d'info su l'erreur utilise or die
    0
  2. Steevy
     
    Essaye ça ca fonctionnera déjàs mieux

    <?
    function notification_reponse() {
    global $topic_last_post_link, $topic_id;
    
    $header = "FROM: ".bb_get_option("from_email")."\n"; 
    $header .= "Content-type: text/html; charset= iso-8859-1\n";
    
    $msg =__("<p>Vous avez reçu une réponse pour votre question posée sur le forum commentguerir.</p><p>Pour lire cette réponse veuillez visiter cette page :</p>").get_topic_last_post_link($topic_id).__("<p>Pour ne plus recevoir de notifications, veuillez répondre à cet email avec comme titre: désinscription</p>");
    $msg = utf8_decode($msg);
    
    $niv1= mysql_query("SELECT post_id FROM bb_posts WHERE topic_id=".$topic_id."") or die ('Erreur SQL !'.$niv1.'<br>'.mysql_error());
    while ($donnee1=mysql_fetch_array($niv1)){
    
    $all = mysql_query("SELECT meta_value FROM bb_meta WHERE meta_key = 'post_email' and object_id = ".$donnee1["post_id"]."") or die('Erreur SQL !'.$all.'<br>'.mysql_error());
    while ($donnee2 = mysql_fetch_array($all)){
    
    $lastpost=mysql_query("SELECT topic_last_post_id FROM bb_topics WHERE topic_id=".$topic_id."") or die('Erreur SQL !'.$lastpost.'<br>'.mysql_error());
    $lastpost1=mysql_fetch_array($lastpost);
    if ($donnee1["post_id"]!=$lastpost1["topic_last_post_id"]){
    bb_mail($donnee2["meta_value"], "Une réponse à votre question", $msg, $header);
    }
    	}
    		}
    			}
    ?>
    0