Page 1 of 1

getting errors .... mysql_fetch_array ....

Posted: Sat Feb 19, 2005 11:57 pm
by HormonX
this the code i used many times before and it workd just fine .. not it doesn't .... can anyone find something wrong with this ? :)

The code works great when i initially log in .. i shows the number of messages for tthe user .. but as soon i click on a link to display messages i get this error .....

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/domain/public_html/portal/sindex.php on line 56

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/domain/public_html/portal/sindex.php on line 59

Code: Select all

<?
	  		$query = "SELECT * FROM table1 WHERE username='user'";
			$result = mysql_query($query, $link);
			
			while($row = mysql_fetch_array($result))
			&#123;
			
			$uid = $row&#1111;'uid'];
					
			$count = mysql_query("SELECT COUNT(*) FROM msg_system WHERE msg_to='$uid' AND msg_viewed='0'");
			$counter=mysql_result($count,0);
			
		  ?>
		  <td align="right" height="20"><a href="?page=msg&uid=<? echo $uid; ?>">your mail&#1111;<? echo $counter; ?>]</a> 
		  <?
		  &#125;
thank you.

Greg

Posted: Sun Feb 20, 2005 12:26 am
by feyd
place the usual mysql debugging stuffs:

Code: Select all

mysql_query(...) or die(mysql_error());

Posted: Sun Feb 20, 2005 12:28 am
by thegreatone2176
$query = "SELECT * FROM table1 WHERE username='user'";

add a $ in 'user'

and its always good a idea to put or die(mysql_error()) after $result

also the code would like alot cleaner if you just echoed all the html out instead of ?> <? everywhere

Posted: Sun Feb 20, 2005 7:02 am
by d3ad1ysp0rk
It'd be even cleaner if he built output variables then used them below, essentially putting all his html together..

theres tons of ways to do everything, I think his way is fine ;)