hey guys what is wrong with my mysql_fetch_array
here is my code :

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td>
<strong><h2>Welcome to Our Website</h2></strong>
</td>
</tr>
</table>
<br />
<?
$mysql_host = "localhost";
$mysql_database = "members";
$tbl_name = "posts";
mysql_connect('localhost','admin','*******')or die("can not connnect to database");
mysql_select_db("$mysql_database")or die("sorry , can not sellect db");
$sql="SELECT*FROM $tbl_name";
$result=mysql_query($sql);
while($rows = mysql_fetch_array("$result"))
{
?>
<table width="400" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
<tr><td>
<table width="400" border="0" cellpadding="2" cellspacing="1" bgcolor="#ffffff">
<tr>
<td>Title : <? echo $rows['title']; ?></td>
</tr>
<tr>
<td> <?   echo $rows['post']; ?> </td>
</tr> 
</table></td></tr> <? } ?></table>
<? mysql_close(); ?>

and here is the error :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/zxq.net/a/w/a/awah/htdocs/add_email_test/admin/view-posts.php on line 19

:?:

Recommended Answers

All 4 Replies

Remove the double quotes. It expects a variable containing a resource, not a string.

use

while($rows = mysql_fetch_array($result))
$sql="SELECT * FROM $tbl_name";

$result=mysql_query($sql);

while($rows = mysql_fetch_array($result))

replace with above code and try

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.