Xtremer360 Posted November 1, 2010 Share Posted November 1, 2010 I keep getting a resource #6 at the top of my script and not sure why. <?php if (isset($_REQUEST['option'])) { switch ($_REQUEST['option']) { case 0: ?> <h1 class="backstage">Biographies Management</h1><br /> <h2 class=backstage>Bio Types</h2><br /> <?php $query = "SELECT * FROM efed_list_styles AS styles"; $result = mysql_query ( $query ); $rows = mysql_num_rows($result); if ($rows > 0) { print'<table width="100%" class="table1"> <tr class="rowheading"> <td> </td> <td width="40" align="center">ID</td> <td>Name</td> </tr>'; $i = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $sClass = 'row2'; if ($i++ % 2) $sClass = 'row1'; printf ( "<tr class=\"%s\">", $sClass ); print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('backstage_libs/biolayout.php?option=1&id=$row[id].', 'content'); return false;\">Edit</a></td>"; printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row ['id'] ); printf ( "<td valign=\"top\">%s</td>", $row ['name'] ); echo '</tr>'; } echo '</table><br>'; } else { echo '<span>There are no bio types.</span><br /><br />'; } returnmain(); footercode(); break; case 1: require_once('../backstageconfig.php'); require_once('../backstagefunctions.php'); $id = $_GET['id']; $query = mysql_query("SELECT * FROM `efed_list_styles` WHERE `id` = '" . $id . "'"); $row = mysql_fetch_array($query); echo $query; ?> <h1 class="backstage">Bio Layouts Management</h1><br /> <h2 class="backstage"><?php echo $row['name']; ?> Biography Layout</h2><br /> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/ Share on other sites More sharing options...
Maq Posted November 1, 2010 Share Posted November 1, 2010 I can only assume case: 1 is true and you're echoing $query which is only a resource. Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129176 Share on other sites More sharing options...
Xtremer360 Posted November 1, 2010 Author Share Posted November 1, 2010 Well what is in that I need to do to adjust it so that if I echo the query it'll echo it correctly. Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129177 Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2010 Share Posted November 1, 2010 EDIT: I was beaten to it . . . This line is suspect as it would likely hold a resource: echo $query; Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129178 Share on other sites More sharing options...
Xtremer360 Posted November 1, 2010 Author Share Posted November 1, 2010 I've echoed a lot of my queries and I've never had a resource id come out. Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129180 Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2010 Share Posted November 1, 2010 You've probably echoed the query strings, not the query result. $query = "SELECT * FROM `table`; $result = mysql_query( $query ); echo $query; What you have in the code above would be equivalent to echo $result; Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129183 Share on other sites More sharing options...
Maq Posted November 1, 2010 Share Posted November 1, 2010 I've echoed a lot of my queries and I've never had a resource id come out. Doubtful. mysql_query returns a resource id, and that's what you're seeing. What are you trying to echo exactly? If you want to echo the 'query' you're going to have to put it into a string first. If you want data, $row is holding your fetched result set array. That's where the data is. Link to comment https://forums.phpfreaks.com/topic/217490-resource-6/#findComment-1129184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.