Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undefined Variable & Supplied argument invalid

Status
Not open for further replies.

ScottCybak

Programmer
Sep 29, 2000
48
CA
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)

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 &quot;<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'> &quot;;

	print $line1[&quot;CatDesc&quot;];
	print &quot;</td></tr></table></td></tr><tr>&quot;;

	//Display results in generic format

	$rowcount = 1;
	$comparison = $rowcount % 2;

        //error happens on the next line
	while($line = mysql_fetch_array ($result)) {

		print &quot;<td class='&quot;;
		if ($comparison != 0) {
			print &quot;lighttable&quot;;
		} else {
			print &quot;darktable&quot;;
		}
		
		//continue with formatting
		print &quot;'>&quot;;
		print $line[&quot;PostTitle&quot;];
		print &quot; <small><i>Posted on &quot;;
		print &quot;<a href='mailto:&quot;;
		print $line[&quot;EmailAdd&quot;];
		print &quot;'> &quot;;
		print $line[&quot;FirstName&quot;].&quot; &quot;.$line[&quot;LastName&quot;];
		print &quot; on &quot;;
		print $line[&quot;PostDate&quot;];
		print &quot;</i></small><br><div style='margin-left:10px;'>&quot;;
		print $line[&quot;PostBody&quot;];
		print &quot;</div></td></tr></table></td></tr></table>&quot;;
		$rowcount++;

	}
}
?>

I'm new to PHP and i'm unsure what's wrong with this.. anybody?
Scott Cybak
scott@athree.com
 
hi
i found that the mysql_query which gives resultid $result is commented ..error can be because of that..

cheers

spookie
 
.. ...

i didn't even see that

i'm not at work right now, so i'm kinda S.O.L. for now, i hope this is it

how sthupid of me to overlook that.. ahahahah

Thanks spook Scott Cybak
scott@athree.com
 
LMFAO

that was it.. ahahahah

Now, to figure out why i'm getting duplicates.

THanks again! Scott Cybak
scott@athree.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top