Jump to content

[SOLVED] Offsets not working


ecopetition

Recommended Posts

Hello,

 

I'm trying to make an attachments mod for a forum software. It is to allow me to upload attachments in a forum post, and although it works it also returns the following error in the header:

[NuclearBB Notice] Undefined offset: 1 (Line 350, File viewtopic.php)

 

Codes:

// Check if post has an attachment
$sql = "SELECT human_name
		FROM attachments
		WHERE post_id = ". $posts[$i]['post_id'] ."
		";
$result = $db->query($sql);
while($row = $db->fetch_assoc($result))
{
	$attachment_name[] = $row;
}

$template->assign_block_vars('post', array(
	'ATTACHMENT_NAME'			=>	($attachment_name[$i]['human_name']),
));

 

The variable "$i" controls the offset depending on which post I'm on, and not every post has an attachment (and therefore an according line in the "attachments" table).

 

Thank you for your help.

Link to comment
https://forums.phpfreaks.com/topic/117370-solved-offsets-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.