Jump to content

Error: Resource id #33


monkeypaw201

Recommended Posts

I have some code....

 

<?php
mysql_select_db($database_vamsys, $vamsys);
$query_rank = sprintf("SELECT * FROM vamsys_ranks");
$rank = mysql_query($query_rank, $vamsys) or die(mysql_error());
$row_rank = mysql_fetch_assoc($rank);
$totalRows_rank = mysql_num_rows($rank);

if($row_hour_count['hour_count'] > $row_rank['hours'])
{
$rank = $row_rank['title'];
}
?>

 

and when i try to display $rank with

<?php echo $rank; ?>

 

i get the following displayed:

Resource id #33

 

I have no clue what that means... any help?

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/
Share on other sites

ah, I see. then try this:

<?php
mysql_select_db($database_vamsys, $vamsys);
$query_rank = sprintf("SELECT * FROM vamsys_ranks");
$rank = mysql_query($query_rank, $vamsys) or die(mysql_error());
$row_rank = mysql_fetch_assoc($rank);
$totalRows_rank = mysql_num_rows($rank);

if($row_hour_count['hour_count'] > $row_rank['hours'])
{
$rank1 = $row_rank['title'];
print $rank1;
}
else{
print "Row Hour count is not greater than row_rank(Hours)"; 
//this will tell you if you're not meeting the requirements.
}
?>

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549019
Share on other sites

The resource id#331 means that you made a query to the db and it returned a result (as opposed to failing for whatever reason and returning false). 

 

The good news is that that means your query is okay. From there, first thing I would check is to make sure that 'title' is actually a column name (spelled right, etc..) in your vamsys_ranks table.

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549022
Share on other sites

ah, I see. then try this:

<?php
mysql_select_db($database_vamsys, $vamsys);
$query_rank = sprintf("SELECT * FROM vamsys_ranks");
$rank = mysql_query($query_rank, $vamsys) or die(mysql_error());
$row_rank = mysql_fetch_assoc($rank);
$totalRows_rank = mysql_num_rows($rank);

if($row_hour_count['hour_count'] > $row_rank['hours'])
{
$rank1 = $row_rank['title'];
print $rank1;
}
else{
print "Row Hour count is not greater than row_rank(Hours)"; 
//this will tell you if you're not meeting the requirements.
}
?>

 

output...

 

Row Hour count is not greater than row_rank(Hours)

 

so now i have a slight dilemma.. i need to select the rank of a user based on how many hours they have and then display that, but i tried looking it with a do..while loop which caused a lot of errors... im not sure how i can get it to do what i want... do you have any recommendations?

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549023
Share on other sites

farther up the page:

 

<?php
$colname_hour_count = $_SESSION['pilot_id'];
if (isset($_GET['pilot_id'])) {
  $colname_hour_count = $_GET['pilot_id'];
}
mysql_select_db($database_vamsys, $vamsys);
$query_hour_count = sprintf("SELECT SUM(time_enroute) AS hourcount FROM vamsys_pireps WHERE pilot_id = %s AND status = 'Approved'", GetSQLValueString($colname_hour_count, "text"));
$hour_count = mysql_query($query_hour_count, $vamsys) or die(mysql_error());
$row_hour_count = mysql_fetch_assoc($hour_count);
$totalRows_hour_count = mysql_num_rows($hour_count);
?>

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549028
Share on other sites

have you tried doing a different query, something like (I'm just using examples, mind you)

SELECT `user`, `hours` FROM `vamsys_pireps` ORDER BY `hours` DESC;

This would give you all your users, from most hours to least hours.  You could then add them into 2 arrays (or a multi dimensional array), and update their rank from there.

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549033
Share on other sites

have you tried doing a different query, something like (I'm just using examples, mind you)

SELECT `user`, `hours` FROM `vamsys_pireps` ORDER BY `hours` DESC;

This would give you all your users, from most hours to least hours.  You could then add them into 2 arrays (or a multi dimensional array), and update their rank from there.

 

Well they each have their own "WHERE" statements and i don't think you can mix them, can you?

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549035
Share on other sites

Now... i am looking at using something like this:

 

<?php
if($row_hour_count['hour_count'] > $row_rank['hours'])
{
$rank1 = $row_rank['title'];
}
elseif($row_hour_count['hour_count'] > $row_rank['hours'])
{
$rank1 = $row_rank['title'];
}
?>

 

but i need the IF statement to have the first result, and the ELSEIF have the second, with the ELSEIF looping to check all results

Link to comment
https://forums.phpfreaks.com/topic/107091-error-resource-id-33/#findComment-549038
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.