Jump to content

Archived

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

l33t_script3r

Invalid resource using mysql_fetch_array and assoc

Recommended Posts

Hey!

ill cut to the chase [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]
when i use this code:

[code]$topiclist = mysql_query("SELECT * FROM forums_topics ORDER by id DESC");
while($row_topics = mysql_fetch_assoc($topiclist)){
?>
test
<? } ?>[/code]

and preview it, it comes up with this error:

[code]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\bloodspill\index.php on line 110[/code]

tia for your help

Share this post


Link to post
Share on other sites
question:

- did you connected to database, did you select the database schema?
- did forums_topics table exist in your schema?

Share this post


Link to post
Share on other sites
I didn't see anything wrong with the snippet you posted.
Can you post the more code and indicate the line 110.

Share this post


Link to post
Share on other sites
[code]

$db=mysql_connect("localhost","username","password");

mysql_select_db("database name",$db);

$topiclist ="SELECT * FROM forums_topics ORDER by id DESC";

$result=mysql_query($topiclist);

while($row_topics = mysql_fetch_assoc($topiclist)){

while(list($title,$data)=each($row)){
?>
echo "<br> $title : $data <br>";
<?
}
}
?>
[/code]

Share this post


Link to post
Share on other sites
errrm lol what was that for? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

anyways...

its just that table that isnt working, i even copied the name of the table from phpmyadmin and it didnt work...
i tried a different table and it worked fine, not sure what is going on here

Share this post


Link to post
Share on other sites

×

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.