counting replies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Are you still getting an error similar to this?
SELECT count(postID) AS rowcount FROM comments WHERE postID=
If so, go to this area and add this

Code: Select all

while ($row = mysql_fetch_array($result, MYSQL_NUM))
      {   
         //puta

Code: Select all

print_r($row);
Do a view source and grab the stuff that mentions array and post it here.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

here is what appears
Array ( [0] => March 2nd, 2005 - 10:41 PM [1] => 14the report [2] => 16 [3] => pleigh ) pleigh
14the report
1
March 2nd, 2005 - 10:41 PM

Array ( [0] => March 2nd, 2005 - 5:53 PM [1] => new topic [2] => 17 [3] => jeff ) jeff
new topic
2
March 2nd, 2005 - 5:53 PM

Array ( [0] => March 2nd, 2005 - 3:21 PM [1] => 13th report [2] => 15 [3] => pleigh ) pleigh
13th report
0
March 2nd, 2005 - 3:21 PM

Array ( [0] => March 2nd, 2005 - 3:18 PM [1] => 12th report [2] => 14 [3] => pleigh ) pleigh
12th report
0
March 2nd, 2005 - 3:18 PM

Array ( [0] => March 2nd, 2005 - 3:17 PM [1] => 11th report [2] => 13 [3] => pleigh ) pleigh
11th report
0
March 2nd, 2005 - 3:17 PM

Array ( [0] => March 1st, 2005 - 9:08 PM [1] => 10th report [2] => 12 [3] => pleigh ) pleigh
10th report
3
March 1st, 2005 - 9:08 PM

Array ( [0] => March 1st, 2005 - 8:12 PM [1] => 9th report [2] => 11 [3] => pleigh ) pleigh
9th report
0
March 1st, 2005 - 8:12 PM

Array ( [0] => March 1st, 2005 - 8:11 PM [1] => 8th report [2] => 10 [3] => pleigh ) pleigh
8th report
0
March 1st, 2005 - 8:11 PM

Array ( [0] => March 1st, 2005 - 8:09 PM [1] => 7th report [2] => 9 [3] => pleigh ) pleigh
7th report
0
March 1st, 2005 - 8:09 PM

Array ( [0] => March 1st, 2005 - 8:08 PM [1] => 6th report [2] => 8 [3] => pleigh )
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

That looked normal. What is happening?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

honestly, i really have no idea.. :) ...but the code is working except for the error message that i am receiving
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Is it the same error message? Is this site somewhere that I can see it?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

yah, this one
Warning: Missing argument 1 for replies() in c:\inetpub\wwwroot\mysample\functions\library.php on line 321
Error with SELECT count(postID) AS rowcount FROM comments WHERE postID=
if i am not mistaken, it is in the query that causes the problem.....or the arguement...really don't know....
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

So what is on line 321 in the library.php file?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Just wondering... What happens if you change

Code: Select all

<td width=10% class=tableborder><table><tr><td>".replies($row&#1111;2])."</td></tr></table></td>
to

Code: Select all

<td width=10% class=tableborder><table><tr><td>".replies(floor($row&#1111;2]))."</td></tr></table></td>
I take it postID is a number.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

hi guys, sori about last night....i went home to rest.....to continue my problem, i did what coder ask me

changed this line from

Code: Select all

<td width=10% class=tableborder align=center><table><tr><td>".replies($row&#1111;2])."</td></tr></table></td>
to this one

Code: Select all

<td width=10% class=tableborder align=center><table><tr><td>".replies(floor($row&#1111;2]))."</td></tr></table></td>
the same error prompts
Warning: Missing argument 1 for replies() in c:\inetpub\wwwroot\mysample\functions\library.php on line 321
Error with SELECT count(postID) AS rowcount FROM comments WHERE postID=
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

So back to my original question. What is line 321 in the file c:\inetpub\wwwroot\mysample\functions\library.php?

I want to see just that line.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

thanks smpdawg...this is the line

Code: Select all

function replies($postID)
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

[SOLVED]

Post by pleigh »

put this line of code before the mysql query to debug the error

Code: Select all

function replies($postID)
&#123; 
     if(empty($postID)) 
    &#123;
        echo '<pre>';
        var_dump(debug_backtrace());
        echo '</pre>';
    &#125;
    //other codes goes here
&#125;
i found out that the viewing page has a problem

thanks for the time guys....
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

btw, if i understand a little, if a post doesn't have comments, i won't appear in the resultset. usually this is unwanted, and it should say there are 0 comments instead...


i solve this like:

Code: Select all

SELECT 
  m.message_id AS message_id, 
  m.datetime AS datetime, 
  IF(ISNULL(comment_id), 0, COUNT(*)) AS count 
FROM 
  message AS m 
  LEFT JOIN comment AS c USING (message_id) 
GROUP BY 
  m.message_id
Post Reply