i have a ver starbge problem , i was making a site and was completly correct on the localhost,but when i upload irt to a server to test it something stange happened which is i got that error
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/saraanv/public_html/blog_web/index.php on line 10

this is the code part which has the error , any help plzz?

<?php 
		
		include 'config.php';
		$q="select * from `topic` order by `id` desc";
		$result=mysql_query($q);
		echo "<table>";
		for ($i=0;$i<8;$i++)
		{
			echo "<tr>";
			$topic_id=mysql_result($result,$i,'id');
			$topic_name=mysql_result($result,$i,'title');
			$num_char=strlen($topic_name);
			//echo $num_char;
			if ($num_char>25)
			{
				
				echo "<td>";
				echo "<a href='show_topic.php?id=$topic_id'>";
				echo "<font color='#002248' face='Times New Roman, Times, serif' size='2'>";
			    echo substr($topic_name,0,30);
			    echo "</font>";		
				echo "</a>";
				echo "......";
				echo "</td>";
				
			}
			else 
			{
				echo "<td>";
				echo "<a href='show_topic.php?id=$topic_id'>";
				echo "<font color='#002248' face='Times New Roman, Times, serif' size='2'>";
			    echo $topic_name;
			    echo "</font>";		
				echo "</a>";
				echo "</td>";
			}
                echo "<td>";
				echo "<a href='show_topic.php?id=$topic_id'>";	
				echo "<img src='images/Plus.png' height='20' width='20' align='left' border='0' />";
				echo "</a>";
				echo "</td>";
				echo "</tr>";
				
		}
	echo "</table>";
		?>

Recommended Answers

All 4 Replies

Did you mean line 11, not 111?
The code should still run even with a warning -- is your output correct?

i meam line 10 not 111 , which has the follwing statement
$topic_id=mysql_result($result,$i,'id');
, but there is no output only these warning

Member Avatar for Zagga

Hi sara nabil,

I had a similar error when running multiple mysql_result statements on the same variable ($result).
Try resetting the file pointer between the statements (line 10 and 11).

$topic_id=mysql_result($result,$i,'id');
mysql_data_seek($result,'0');
$topic_name=mysql_result($result,$i,'title');

Hope this helps.
Zagga

i tried what you say , but still have the same warning

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.