ScottCybak
Programmer
Hi, i'm getting this message:
Warning: Undefined variable: result in c:\inetpub\ on line 36
Warning: Supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 36
When i try to run the following snippet of code (posted it all, as i don't know what i need/don't need)
I'm new to PHP and i'm unsure what's wrong with this.. anybody?
Scott Cybak
scott@athree.com
Warning: Undefined variable: result in c:\inetpub\ on line 36
Warning: Supplied argument is not a valid MySQL result resource in c:\inetpub\ on line 36
When i try to run the following snippet of code (posted it all, as i don't know what i need/don't need)
Code:
//Generate category listing
$result1 = mysql_query("SELECT * FROM tblcategories");
//Loop through categories
while($line1 = mysql_fetch_array($result1)){
//generate new query based on current category
//$result = mysql_query("SELECT PostNum, DATE_FORMAT(PostDate, '%M %D, %Y') AS PostDate, PostTitle, PostBody, FirstName, LastName, EmailAdd, tblcategories.CatNum, CatDesc FROM (tblposts LEFT JOIN tblusers ON tblposts.UserNum = tblusers.UserNum) LEFT JOIN tblcategories ON tblposts.CatNum = tblcategories.CatNum WHERE tblcategories.CatNum = 1 ORDER BY PostDate DESC");
//build category header
print "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td class='tableborders'><table width='100%' cellpadding='3' cellspacing='1' border='0'><tr><td class='tdheader' align='center'><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td align='left' class='tdheader'> ";
print $line1["CatDesc"];
print "</td></tr></table></td></tr><tr>";
//Display results in generic format
$rowcount = 1;
$comparison = $rowcount % 2;
//error happens on the next line
while($line = mysql_fetch_array ($result)) {
print "<td class='";
if ($comparison != 0) {
print "lighttable";
} else {
print "darktable";
}
//continue with formatting
print "'>";
print $line["PostTitle"];
print " <small><i>Posted on ";
print "<a href='mailto:";
print $line["EmailAdd"];
print "'> ";
print $line["FirstName"]." ".$line["LastName"];
print " on ";
print $line["PostDate"];
print "</i></small><br><div style='margin-left:10px;'>";
print $line["PostBody"];
print "</div></td></tr></table></td></tr></table>";
$rowcount++;
}
}
?>
I'm new to PHP and i'm unsure what's wrong with this.. anybody?
Scott Cybak
scott@athree.com