Presto-X Posted April 17, 2009 Share Posted April 17, 2009 What does this mean? is it an error with our php code or mysql query, I'm guessing it has to do with our query but I'm not sure, please help. mysql_select_db($database_biosystem); $query_content = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query_content); $row_content = mysql_fetch_assoc($content); do { echo "<div>".$row_content['title']."</div>"; } while ($row_content = mysql_fetch_assoc($content)); ?> Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/ Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 You were using the resource id to echo the extracted rows. Try this: mysql_select_db($database_biosystem); $query_content = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query_content); while ($row = mysql_fetch_assoc($content)) { echo "".$row['title'].""; } ?> Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812452 Share on other sites More sharing options...
Presto-X Posted April 17, 2009 Author Share Posted April 17, 2009 Thanks for the fast reply Maq, The message is now Resource id #128 Here is my updated code $query = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query); while ($row = mysql_fetch_assoc($content)) { echo "<div>".$row['title']."</div>"; } Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812468 Share on other sites More sharing options...
ober Posted April 17, 2009 Share Posted April 17, 2009 That code looks fine. Are you sure that error isn't coming from another part of the page? Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812476 Share on other sites More sharing options...
Presto-X Posted April 17, 2009 Author Share Posted April 17, 2009 Good question, this code is for a custom Joomla module, I have built a lot of them and have never seen this before, if I disable the module or comment out all of the code the message goes away, here is all of the code I am using with in the module: <div align="left" style="margin-bottom:15px;"><img src="templates/bcrc/images/latest_news.png" alt="" /></div> <?php // no direct access defined('_JEXEC') or die('Restricted access'); $query = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query); while ($row = mysql_fetch_assoc($content)) { echo "<p>".$row['title']."</p>"; } echo '<p>'.$params->get('catid').'</p>'; Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812481 Share on other sites More sharing options...
ober Posted April 17, 2009 Share Posted April 17, 2009 If you comment out from the $query to the end of the while loop, do you still get it? Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812484 Share on other sites More sharing options...
mtoynbee Posted April 17, 2009 Share Posted April 17, 2009 That message normally means you are echoing a database execution rather than a variable. Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812485 Share on other sites More sharing options...
Presto-X Posted April 17, 2009 Author Share Posted April 17, 2009 Ober, if I comment out the code like the following the message goes away: <div align="left" style="margin-bottom:15px;"><img src="templates/bcrc/images/latest_news.png" alt="" /></div> <?php // no direct access defined('_JEXEC') or die('Restricted access'); /* $query = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query); while ($row = mysql_fetch_assoc($content)) { echo "<p>".$row['title']."</p>"; } */ echo '<p>'.$params->get('catid').'</p>'; Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812502 Share on other sites More sharing options...
Presto-X Posted April 17, 2009 Author Share Posted April 17, 2009 I just posted a message on Joomla's forum, I'm stumped, I have never had this problem before very odd. Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812509 Share on other sites More sharing options...
ober Posted April 17, 2009 Share Posted April 17, 2009 <div align="left" style="margin-bottom:15px;"><img src="templates/bcrc/images/latest_news.png" alt="" /></div> <?php // no direct access defined('_JEXEC') or die('Restricted access'); $query = "SELECT title, introtext, created FROM jos_content WHERE state=1 AND sectionid=1 AND catid=1 ORDER BY ordering"; $content = mysql_query($query); if($content && mysql_num_rows($content) > 0) { while ($row = mysql_fetch_assoc($content)) { echo "<p>".$row['title']."</p>"; } } echo '<p>'.$params->get('catid').'</p>'; Time to go error trapping... Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812510 Share on other sites More sharing options...
mtoynbee Posted April 17, 2009 Share Posted April 17, 2009 Where is your database connection string? Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812513 Share on other sites More sharing options...
Presto-X Posted April 17, 2009 Author Share Posted April 17, 2009 same thing you can view the page here, look to the footer of the page in the gray under "Latest News", http://bcr.c-s-wilson.com Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812515 Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 This is your error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/presto/public_html/bcr/modules/mod_latestnews1/mod_latestnews1.php on line 11 Means your query is failing. Change your code to this and tell me what it outputs (should be a MySQL error): $content = mysql_query($query) or die(mysql_error()); 'state', 'sectionid', and 'catid' are all integer types in your table right? Link to comment https://forums.phpfreaks.com/topic/154525-resource-id-132-at-the-end-of-our-content/#findComment-812558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.