runnerjp Posted November 14, 2008 Share Posted November 14, 2008 this is new to me so here it goes... $query = "SELECT fe.*, u.email, u.id FROM forum_email as fe LEFT JOIN users as u on u.ID = fe.id WHERE topic_id = '".$forumpostid."' AND fe.user_id != '".$id."' AND mailed='n'"; $res = @mysql_query($query) or die ("sendNotification query fails :".mysql_error()); theres my query but i keep getting told im getting the data from the wrong tables... this is where im puliing it from table = users ID and from my other one table = forum_emails user_id topic_id mailed so form that where have i gone wrong :S Link to comment https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/ Share on other sites More sharing options...
BenInBlack Posted November 14, 2008 Share Posted November 14, 2008 in your from you have "forum_email as fe" it should be "forum_email fe" you only use the "as" in column aliasing Link to comment https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/#findComment-690275 Share on other sites More sharing options...
runnerjp Posted November 14, 2008 Author Share Posted November 14, 2008 did that now i get sendNotification query fails :Unknown column 'fe.id' in 'on clause' just getitng to learn these join statements Link to comment https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/#findComment-690280 Share on other sites More sharing options...
runnerjp Posted November 14, 2008 Author Share Posted November 14, 2008 sorry fixed that... but now for sending emails i get Warning: Invalid argument supplied for foreach() in /home/runningp/public_html/members/include/reply.php on line 75 <? $query = "SELECT fe.*, u.email, u.id FROM forum_email fe LEFT JOIN users as u on u.ID = fe.user_id WHERE topic_id = '".$forumpostid."' AND fe.user_id != '".$id."' AND mailed='n'"; $res = @mysql_query($query) or die ("sendNotification query fails :".mysql_error()); //nobody wants an email, stop now if(count($id) == 0): return; endif; foreach($id as $value) { //define the receiver of the email $to = $userinfo['email']; //define the subject of the email $subject = 'Test email'; //define the message to be sent. Each line should be separated with \n $message = "im sending an email too myself."; //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; }?> Link to comment https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/#findComment-690290 Share on other sites More sharing options...
Barand Posted November 14, 2008 Share Posted November 14, 2008 in your from you have "forum_email as fe" it should be "forum_email fe" you only use the "as" in column aliasing "AS" is optional Link to comment https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/#findComment-690440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.