Jim R Posted October 15, 2020 Share Posted October 15, 2020 (edited) I assuming if you're here, you know WP table structure, but I also have two of my own tables called events and evaluations. Events columns are id, name, start, end, city, state, tag Evaluations isn't really part of this issue. I have a WP Page with custom code drawing anything from Evaluations that matches the Event to the page. Now, I would also like to list any WP Post that matches event.tag to this page. The error I'm getting: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home2/csi/public_html/wp-content/plugins/csi_reviews.php on line 970 So it's not finding any matches in the query, but I work it forward and back, the values line up. So I'm clearly missing something. So the URL that reads like this... webaddress.com/event/?event=18 $event = $_GET['event']; $query = "SELECT * FROM wp_posts p LEFT JOIN wp_terms_relationships tr ON p.ID = tr.object_id LEFT JOIN wp_terms t ON tr.term_taxonomy_id = t.term_id LEFT JOIN a_events e ON e.tag = t.slug WHERE e.id = '". $event ."' "; p.ID = 1459 tr.object_id = 1459 tr.term_taxonomy_id = 1231 t.term_id = 1231 e.tag = mibfl t.slug = mibfl e.id = 18 $event = 18 Edited October 15, 2020 by Jim R Quote Link to comment https://forums.phpfreaks.com/topic/311604-trying-to-call-up-posts-that-match-the-tag-in-the-post-to-a-keyword-in-my-own-data-table/ Share on other sites More sharing options...
requinix Posted October 15, 2020 Share Posted October 15, 2020 After you fix the SQL injection problem with $event, The error message means your query failed because of a syntax error. Try running the query yourself manually to see what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/311604-trying-to-call-up-posts-that-match-the-tag-in-the-post-to-a-keyword-in-my-own-data-table/#findComment-1581914 Share on other sites More sharing options...
Jim R Posted October 15, 2020 Author Share Posted October 15, 2020 Turns out it was just a typo. wp_terms_relationships - there shouldn't be an 's' in terms. Sorry about that. I should've run the basic query to see if I could get more info. Quote Link to comment https://forums.phpfreaks.com/topic/311604-trying-to-call-up-posts-that-match-the-tag-in-the-post-to-a-keyword-in-my-own-data-table/#findComment-1581917 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.