I always get this error and it seems that I can't solve it :mad:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site51/fst/var/www/html/td/main/item.php on line 13
this is the code:
item.php
<?php
include('news/db.php');
if (isset($_GET["id"])){
$q = mysql_query("SELECT * FROM $table WHERE id = '".$_GET['id']."'");
} else {
echo "no item selected";
}
// That queries the database
echo "<br><br>";
while($r=mysql_fetch_array($q)){
$title = $r["title"];
$news = $r["news"];
$body = nl2br($news);
$author = $r["author"];
$link = "mailto:".$r["email"];
$date = $r["date"];
if($table == 'td_downloads') {
$download = $r["link"];
}
echo "<table width=$contentwidth border=0 cellpadding=0 cellspacing=0>
<tr>
<td height=\"30\" width=\"21\" background=\"images/leftup.png\"></td>
<td height=\"30\" colspan=\"3\" background=\"images/up.png\">$what</td>
<td height=\"30\" width=\"21\" background=\"images/rightup.png\"></td>
</tr>
<tr>
<td width=\"21\" background=\"images/left.png\"></td>
<td colspan=3 background=\"images/spacer_content.png\">
<font class=\"news\">Category: <font class=\"fakelinknews\">$what</font><br>
<font class=\"fakelinknews\">\"$title\"</font> posted by <a class=\"linknews\" href=\"$link\">$author</a>
on <font class=\"fakelinknews\">$date</font></font><br><br>$body";
if($table == 'td_downloads') {
echo "<br><a href=\"$download\">Download</a>";
}
echo "
</td>
<td width=\"21\" background=\"images/right.png\"></td>
</tr>
<tr>
<td height=\"30\" width=\"21\" background=\"images/leftdown.png\"></td>
<td height=\"30\" colspan=\"3\" background=\"images/down.png\"></td>
<td height=\"30\" width=\"21\" background=\"images/rightdown.png\"></td>
</tr>
</table>
";
}
mysql_close($cnx);
?>
another file passes a variable to this file so this is the url:
http://www.doesntmatter.com/td/main/item.php?id=3