Thanks, it worked perfectly.
Unfortunately, while coding another page, I've encountered yet another error. I receive the following warning when I view one of my pages:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tutorials.php on line 37
Here's the code for that page:
<?php
mysql_select_db('phpBB', mysql_pconnect('localhost','****','*****')) or die (mysql_error());
// Authorise
$allowed_categories = array(
'photoshop',
'flash'
);
$category = $_GET['category'];
//Sets title for page
if(isset($_GET['category'])){
if (in_array($category,$allowed_categories))
{
if ($category = "photoshop") { $page_title="Photoshop Tutorials"; }
if ($category = "flash") { $page_title="Flash Tutorials"; }
}
else {
$page_title = "Tutorial Category does not exist!";
$warning = "Not a valid category!<br /><br />";
}
}
// header
include("./header.php");
if(isset($category)){
echo "$warning";
if (in_array($category,$allowed_categories)){
$query="SELECT * FROM tutorials WHERE category=$category ORDER BY id DESC";
$row=mysql_query($query);
while ($result=mysql_fetch_array($row)){
echo "<img class=\"difficulty\" src=\"***/".$result['difficulty'].".gif\" alt=\"".$result['difficulty']."\" />
<table border=\"0\" width=\"501px\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td valign=\"top\" colspan=\"2\"><img src=\"***/tuts_top.gif\" border=\"0\" alt=\"\" /></td>
</tr>
<tr>
<td valign=\"middle\" class=\"t_bg\">
<div class=\"fl\"> <a href=\"\"><img height=\"90\" with=\"90\" src=\"".$result['thumbnail']."\" alt=\"\" border=\"\" /></a></div>
<b> Title: ".$result['title']."</b><br />
Author: ".$result['author']."<br />
Date Added: ".$result['date']."<br />
Hits: ".$result['hits']."
</td>
</tr>
<tr>
<td valign=\"top\" class=\"t_bg\" colspan=\"2\">Description: ".$result['description']."</td>
</tr>
<tr>
<td valign=\"top\" colspan=\"2\"><img src=\"***/tuts_bottom.gif\" border=\"0\" alt=\"\" /></td>
</tr>
</table>";
}
}
}
if(!isset($_GET['category'])){
echo "You must select a category!<br /><br />";
}
include("./footer.php");
?>
<br /><br />
A bit messy, I know, but I kinda slacked off while trying to filter and validate the results. Luckily, just validating is necessary for this script. Anyway, I have no idea what's wrong. This whole problem appeared when I added some code to set the title of the page depending on $_GET. Unfortunately, it seems like that isn't even working properly as when I type in "tutorials.php?category=photoshop" the title is "Flash Tutorials". I had this working fine before, but I changed something to cause this problem and I don't remember what the change was.
So, I'm hoping someone can help me fix this code and possibly point out a way to make it shorter, cleaner, etc.
Thanks again,
Daniel =)
P.S. Ignore all those tables and stuff. I'll make it valid XHTML using Divs later. =P