Jump to content

fetch MySQL content, error ?


thaidomizil

Recommended Posts

Hello

 

i want to fetch the content from my MySQL db for one table and show it on a page, i'm using this code:

<?php include("inc/connect.php"); ?>
<?php
$result = $_REQUEST['result'];
?>

<?php
$query = mysql_query("select * from listtest order by id asc");
while($result = mysql_fetch_array($query))
{
?>
  <tr>
    <td><?php echo $result['id']; ?></td>
    <td><?php echo $result['code']; ?></td>
    <td align="center"><a href="edit.php?id=<?php echo $result['id']; ?>">View</a></td>

    <td align="center"> </td>
  </tr>
<?php } ?>

 

it's throwing me this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in 32qgtf.php on line 30

 

What am i doing wrong ?

 

/Edit: line 29/30 is the mysql query / fetch.

Link to comment
Share on other sites

It seems like your query is failing. Try changing your query line to

 

$query = mysql_query("select * from listtest order by id asc") or die(mysql_error());

 

and post if there is an error (and what the error is)

 

Note: or die() is never good to use in production. its ok for debugging purposes only.

Link to comment
Share on other sites

If you have phpmyadmin log into there, select your table and then in the mySql box copy and paste the query in.. "select * from listtest order by id asc"  What happens?  Any results?

 

What if you View>Source of the page.  Is anything showing up then?  It could be you have an issue with your html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.