Jump to content

Error during php select


admirolas3

Recommended Posts

Hi. I am getting this kind of an error. Maybe someone knows what i am doing wrong? 
 

Notice: Trying to get property 'total_posts' of non-object in C:\xampp\htdocs\pages\forum\forum.php on line 42

Here is the code: 
 

$update = 'SELECT 
				forum_id
			FROM 
				forum';
$update = $db -> prepare($update);
$update->execute();
while($row = $update -> fetch(PDO::FETCH_OBJ)){
	$post = 'SELECT 
				post_thread, 
				post_datestamp, 
				post_user,
				(SELECT COUNT(post_entry) FROM forum_post WHERE post_forum='.$row->forum_id.') AS total_posts
			FROM 
				forum_post 
			WHERE 
				post_forum='.$row->forum_id.' 
			AND 
				post_datestamp =(SELECT MAX(post_datestamp) FROM forum_post WHERE post_forum='.$row->forum_id.')';
	$post = $db -> prepare($post);
	$post->execute();
	$p_row = $post -> fetch(PDO::FETCH_OBJ);
	$num_of_p = $p_row->total_posts;
	if($num_of_p==null){
		$last_post_date = null;
		$last_post_thread = null;
		$post_user = null;
	}
	else{
		$last_post_date = $p_row->post_datestamp;
		$last_post_thread = $p_row->post_thread;
		$post_user = $p_row->post_user;
	}
	$post=null;
	
	$threads = 'SELECT count(thread_name) as total_threads FROM forum_thread WHERE thread_forum_id='.$row->forum_id.'';
	$threads = $db -> prepare($threads);
	$threads->execute();
	$t_row = $threads -> fetch(PDO::FETCH_OBJ);
	$num_of_t = $t_row->total_threads;
	$threads=null;

	$up_forum = 'UPDATE forum SET forum_threads=?, forum_replies=?, forum_lastpost_user =?, forum_lastpost_date =?, forum_lastpost_thread =? WHERE forum_id ='.$row->forum_id.'';
	$up_forum = $db->prepare($up_forum); 
	$up_forum->execute([$num_of_t, $num_of_p, $post_user, $last_post_date, $last_post_thread]);
	$up_forum=null;
}
$update=null;

 

Link to comment
Share on other sites



  • Posts

    • I am selling the essence project which includes versions 388 and 439 that have been running for over 2 years or (447 as custom PVP like Pride). I have a test server for you to test them out. If you are really interested in it then contact my seller at discord: kiwi7106. Price: 4000 Euro P/s: This is a project that I have spent a lot of money and time developing, so if you are not interested in it, please get out of this topic, thank you. P/s 2: If you find the price too expensive, it's best to skip this article and find another project and don't comment negatively on my topic, thank you.
    • Someone ask me for this, it should work on any client that has Kamael race, preview:     Installation - there are two ways to install depending on how you want to use it:   Method 1: If you want to completely replace the original, do:   Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:   kamael.Mkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_MKamael_m001_w_ad00   Then replace:   MKamael.Mkamael_m000_t00_w   by:   AvengersKamaelWings.MKamael_m001_t00_w   Now repeat the same process with the female, replace:   kamael.Fkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_FKamael_m001_w_ad00   Then replace:   FKamael.Fkamael_m000_t00_w   by:   AvengersKamaelWings.FKamael_m001_t00_w   You're done, paste everything back into File Edit and save!   Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.   Repack by: AvengersTeamBr Password: LadrãoDeFrango      
    • 用于解密、加密和编辑 .u 文件的工具。
    • It's always awesome when you find someone who not only delivers great quality but also does it way ahead of schedule. Makes you feel like you hit the jackpot, right? I'm new around here, just stumbled upon this forum, and seeing posts like yours really gives me hope that there are some real pros hanging out in this community.
  • Topics

×
×
  • Create New...