Search the Community
Showing results for tags 'query echo'.
-
Can someone echo out their $q variable from Chapter 17 Script 17.4 and show me the output? My query is failing as the result of $r is FALSE so I'm getting a Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result when I test forum.php When I echo out the $q variable ( I used echo '<p>The query $q is ' . $q . '</p><br /><br />'; on line 21) I get these results in web browser: The query $q is SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT(CONVERT_TZ(p.posted_on, 'UTC', 'America/New_York'), '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT(CONVERT_TZ(p.posted_on, 'UTC', 'America/New_York'),'%e-%b-%y %l:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = GROUP BY (p.thread_id) ORDER BY last DESC I'm wondering why {$SESSION['lid']} is missing from the output. Here is my line 19 code (matches the book): $q = "SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT($last, '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT($first, '%e-%b-%y %l:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = {$SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC";