Error's Error's

I started getting this error and can not seem to figure it out:

Warning: Invalid argument supplied for foreach() in /home/rgeer3/public_html/comics/comics.html.php on line 52
Warning: Invalid argument supplied for foreach() in /home/rgeer3/public_html/comics/comics.html.php on line 76

Here is the line of code that it is referring to:

	<?php foreach ($Comic as $Splat): ?>
<tr>
<td><?php echo htmlspecialchars($Splat['AuthorName'], ENT_QUOTES,
								'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($Splat['id'], ENT_QUOTES,
								'UTF-8'); ?></td>
</tr>
<?php endforeach; ?>
---------------------------
<?php foreach ($Comics as $Gizmo): ?>
<tr>
<td><?php echo htmlspecialchars($Gizmo['ComicNumber'], ENT_QUOTES,
								'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($Gizmo['ComicName'], ENT_QUOTES,
								'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($Gizmo['ComicTitle'], ENT_QUOTES,
								'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($Gizmo['ComicDate'], ENT_QUOTES,
								'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($Gizmo['AuthorName'], ENT_QUOTES,
								'UTF-8'); ?></td>
</tr>
</form>
<!-- Close PHP containing Comic INFO -->
<?php endforeach; ?>

Here is the array code:

//ARRAY TO HOLD COMIC LIST
while ($row = mysqli_fetch_array($result))
{ $Comics[] = array('id' => $row['id'], 
'ComicNumber' => $row['ComicNumber'], 'ComicName' => $row['ComicName'], 
'ComicTitle' => $row['ComicTitle'], 'ComicDate' => $row['ComicDate'], 
'AuthorName' => $row['AuthorName']);
}
------------------------
//ARRAY TO HOLD AUTHOR LIST
while ($row = mysqli_fetch_array($result1))
{ 
$Comic[] = array('id' => $row['id'], 'AuthorName' => $row['AuthorName']);
}

Figured out that it means there is no content… just can not figure out why, when I do add something, it is not updating again!

Invalid argument pretty much means you’re passing something that isn’t an array to foreach which requires an array.

So before it do something like:


if ($Comic)
{
// foreach loop here
}

// OR

if (is_array($Comic) && !empty($Comic))
{
//foreach
} else {
echo "No articles yet!";
}

So I have narrowed it down to one thing, when I try and add to the author list, it is not updating via the html page:

//FUNCTION TO POST TO AUTHOR LIST
if (isset($_POST['id']))  
{   
foreach ($_POST as $key =&gt; $val) 
{ 
$_POST[$key] = mysqli_real_escape_string($link, $_POST[$key]); 
}     
$id = $_POST['id'];   
$AuthorName = $_POST['AuthorName'];  
              
$sql = "INSERT INTO `ComicAuthor` (`id`, `AuthorName`) 
           VALUES ($id, '$AuthorName')";    
//ERROR TO CHECK LIST  
if (!mysqli_query($link, $sql))   
{   
$error = 'Error adding submitted Author: ' . mysqli_error($link);   
include 'error.html.php';   
exit();   
}     
header('Location: .');
exit();
}
-------------------------
&lt;!-- Call PHP form to create ID/Author --&gt;
&lt;form action="?" method="post"&gt;
&lt;div&gt;
&lt;!-- Create Author ID --&gt;
&lt;label for="id"&gt;Author ID:&lt;/label&gt;
&lt;textarea id="id" name="id" rows="1" cols="10"&gt;&lt;/textarea&gt;
&lt;!-- Create Author Name --&gt;
&lt;label for="ComicAuthor"&gt;Author Name:&lt;/label&gt;
&lt;textarea id="ComicAuthor" name="ComicAuthor" rows="1" cols="10"&gt;&lt;/textarea&gt;
&lt;/div&gt;
&lt;div&gt;&lt;input type="submit" value="Add"/&gt;&lt;/div&gt;
&lt;/form&gt;
&lt;!-- Close PHP form to create ID/Author --&gt;

I actually figured it out… was a typo here:

<label for="ComicAuthor">Author Name:</label>
<textarea id="ComicAuthor" name="ComicAuthor" rows="1" cols="10"></textarea

Should have been labeled “AuthorName”