Jump to content

Resource #6


Xtremer360

Recommended Posts

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

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

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

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.