Jump to content

Recommended Posts

I'll post the entire script since I don't know exactly what the problem is. the error I get is "Warning: Illegal offset type in /home/cheebac8/public_html/videostest.php on line 72." I marked line 72 with a note below:

 

<?php

$mediadir = @scandir("cc08/media");
$i = 0;
foreach ($mediadir as $foldername)
{
if ($foldername=="."||$foldername==".."||$foldername=="error_log"||$foldername==".htaccess")
	{
	// do nothing
	}
else
	{
	$itemlist = @scandir("cc08/media/" . $foldername);
		foreach ($itemlist as $itemname)
		{
		if ($itemname=="."||$itemname==".."||$itemname=="error_log"||$itemname==".htaccess")
			{
			// do nothing
			}
		else
			{
			$catarray[$i] = $itemname;
			$i++;
			}
		}
	}
}
// print_r($catarray);    // all games and videos displayed in a list
foreach($catarray as $key => $val)
{
$explosion[$key] = explode("-",$val);
}
// print_r($explosion);    // all media files in an array showing name, uploader and tag
////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo "<hr />";
foreach($explosion as $item)
{
if (isset($item[2]))
	{
	// tagged
	$tagname = $item[1];
	$num_other_taggeds = count($tags[$tagname]);
	$tags[$tagname][$num_other_taggeds][0] = $item[0];
	$tags[$tagname][$num_other_taggeds][1] = $item[1];
	$tags[$tagname][$num_other_taggeds][2] = $item[2];
	}
else
	{
	//$tagname = "untagged";
	//$num_other_taggeds = count($tags[$tagname]);
	//$tags[$tagname][$num_other_taggeds][0] = $item[0];
	//$tags[$tagname][$num_other_taggeds][1] = $item[1];
	}
}
// print_r($tags);    // organizes items by tag category
function tagged_video_section($tags)
{
foreach ($tags as $category)
	{
?>

<div class="object">
<div class="object_head">
<a name="<?php
	echo $tags[$category][0][1] . "\">" . $tags[$category][0][1];
	?></a>
</div>
<div class="object_cont">
<ul>
<?php
	$i = 0;
	while (isset($tags[$category][$i][0]))  // line 72
		{
		echo "<li><a href=\"" . $items[0] . "-" . $items[1] . "-" . $items[2] . "\">" . preg_replace("/_/"," ",$items[0]) . "</a></li>\n";
		$i++;
		}

	//$catitems = $tags[$category];
	//foreach ($catitems as $items)
	//	{
	//	echo "<li><a href=\"" . $items[0] . "-" . $items[1] . "-" . $items[2] . "\">" . preg_replace("/_/"," ",$items[0]) . "</a></li>\n";
	//	}
?>
</ul>
</div>
</div>

<?php
	}
}
tagged_video_section($tags);
?>

(the code from line 78 to 82 was my first attempt, which got me the same error. I just decided to try a different approach but it didn't help me.)

 

any help is appreciated.

--

also, while I'm here, I get this other error "Warning: Invalid argument supplied for foreach() in /home/cheebac8/public_html/videostest.php on line 14" but that's nothing to worry about since it doesn't mess up the script. I'll find a way to hide it later.

line 72 has me beat i got a similar error a while back and i can't remember how i fixed it but i think i can help you on line 14 i believe the error comes form $itemlist not being an array. you could add a line like this before it

if(is_array($itemlist)){

the close the if the other side of the for each

 

Scott.

from what Crayon Violent said i would think it should be

function tagged_video_section($tags)
{
foreach ($tags as $key => $category)
	{

and

$i = 0;
	while (isset($tags[$key][$i][0]))  // line 72
		{
		echo "<li><a href=\"" . $items[0] . "-" . $items[1] . "-" . $items[2] . "\">" . preg_replace("/_/"," ",$items[0]) . "</a></li>\n";
		$i++;
		}

 

Scott.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.