I just want to dispay all row from mysql table but got error as following:
Note:I am using hostgator and try to display 40,000 query.

Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/firstint/buygadget/sitemapg.php on line 11

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/firstint/buygadget/sitemapg.php on line 13
Value1 	Value2 	Value3 	Value4 	Value5
<html>
<body>
<?php
$username="username1";
$password="123456";
$database="mydatabase";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM affiliSt_products";
$result=mysql_query($query);

$num=mysql_num_rows($result);

mysql_close();
?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Value1</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value2</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value3</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value4</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value5</font></th>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"merchant");
$f2=mysql_result($result,$i,"prodCategory");
$f3=mysql_result($result,$i,"prodName");
$f4=mysql_result($result,$i,"prodBrand");
$f5=mysql_result($result,$i,"prodPrice");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
</tr>

<?php
$i++;
}
?>

</table>
</body>
</html>

Which line that i have do wrong?
Please advice.

Regards,
Wallace

By the looks of things, you aren't connecting to your database correctly, try the following:
Replace your db connection initialisation with the following

mysql_connect(localhost,$username,$password) or die( "Unable to connect to database");
mysql_select_db($database) or die( "Unable to select database");

I just removed the @ from the second line since that could be the original error causing the second two, and I added a die statement to the first line, in case thats where the problem is.

Try it, and then double check your details (username, pwd etc.).
Let me know if you come right :)

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.