Jump to content
Larry Ullman's Book Forums

Recommended Posts

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";

Link to comment
Share on other sites

Thanks for your quick response, I figured it out then came back to delete post and saw you answered.

 

I'm missing the '_' in $_SESSION['lid']

 

I know a lot more about debugging now which is a good thing. :)

 

Hey, since you're reading this can you comment on the errata page for the book? I posted an errata and haven't heard anything.

Link to comment
Share on other sites

 Share

×
×
  • Create New...