0

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

:?:

Edited by Awah Mohamed: error

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by raju_boini525
0

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

Edited by pritaeas: n/a

0
$sql="SELECT * FROM $tbl_name";

$result=mysql_query($sql);

while($rows = mysql_fetch_array($result))

replace with above code and try

Edited by raju_boini525: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.