Jump to content

MYSQL Fetch Array () Warning


smti

Recommended Posts

Hi,

 

I am trying to execute the following query and receive the following error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bloomair/public_html/indexA.php on line 168

 

Here is my code:

 

<? include("includes/newsconnection.inc.php");?>

 

<?

 

// Retrieve data from database

$sql="SELECT * FROM $tbl_name limit 1";

$result=mysql_query($sql);

 

// Start looping rows in mysql database.

while($rows=mysql_fetch_array($result)){

?>

 

 

<b><? echo $rows ['timestamp'];?> - <? echo $rows ['title'];?></span><br></b>

<? echo $rows ['story']; ?> <br>

 

    <a href="pages/news/">View All Notams ></a> <br><br>

         

<?

// close while loop

}

 

// close connection

mysql_close();

?>

 

 

Any help you can provide would be greatly appreciated.

 

Thank You,

 

-smti

 

 

Link to comment
https://forums.phpfreaks.com/topic/149557-mysql-fetch-array-warning/
Share on other sites

This warning usually means, that there your query did not complete successfully.

 

Change:

$result=mysql_query($sql);

 

to

 

$result=mysql_query($sql) or die(mysql_error().": $sql");

 

this will display the actual SQL error and the query that causes it.

 

And please use


tags for posting your code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.