...

View Full Version : resource goes missing after login



madmatter23
08-24-2007, 03:58 AM
I'm having a problem with my code that I just can't seem to figure out. It works perfectly when I'm not logged in, but as soon as a do login, it has trouble finding a referenced resource. The really strange thing is that this page doesn't even use the session variable $username, which is the only thing that changes when I login. The only thing that even references the session on this page at all is the <?php session_start(); ?> at the beginning.

I've marked the line with the missing resource:

Ok, so here's the code:


<?php
foreach ($bubble as $bubblenumber => $value) {
$catname = $bubble[$bubblenumber]["name"];
$catURL = $bubble[$bubblenumber]["URL"];

echo"
<div id=\"bubble".$bubblenumber."\">
<!-- Bubble ".$bubblenumber." -->
<h1> <a href=\"http://www.website.org/$catURL\"> $catname </a></h1>

<div id=\"bubblesubcat\">
<ul>
";

$querysubcategories = "SELECT subcategory FROM subcategories WHERE parent='$catname' ORDER BY subcategory";
$subcategoriesaction = @mysql_query($querysubcategories, $dbc);

$i = 0;

!!! THIS LINE HAS ERROR while (list($subcategoryname) = mysql_fetch_row($subcategoriesaction)) {
$subcategory[$i] = $subcategoryname;
$i = $i + 1;
}

$i = 0;
<!-- this for loop just makes sure that only the first 4 results of the preceding while loop are displayed -->
for ($i = 0; $i <= 4; $i = $i + 1){
$subcategoryname = $subcategory[$i];
echo"
<li><a href=\"http://www.website.org/browse/$catname/$subcategoryname\">$subcategoryname</a></li>
";

}

unset($subcategory);

echo "
</ul>
</div>
<!-- end Bubble subcat -->

<div id=\"more\"><a href=\"http://www.website.org/$catURL\"> More... </a></div>

</div>
<!-- end Bubble ".$bubblenumber." -->
";
}
?>


Also, I tried adding some debugging echos, and it turns out that variables $catname and $catURL are both set correctly. I just don't understand what changes between when I'm logged in and not. How could that affect this code?

I would really appreciate any help that anyone could offer. This is really the last bug for me to work out before I can launch this site. (I think/hope)

CFMaBiSmAd
08-24-2007, 04:15 AM
You would probably get a quicker solution to this if you posted the actual error message.

But I will guess that your mysql_query() function call is failing and since you are both suppressing any error message by using the @ sign and your code has no error checking and error reporting on the mysql_query() results, that it is blindly executing the mysql_fetch_row() function call and receiving an error when it attempts to access a result resource that does not exist.

The mysql examples in the php manual contain error checking logic that you can use to get php/mysql to tell you why your code is not working - http://php.net/mysql_query

madmatter23
08-24-2007, 04:25 AM
Thank for your advice.

This is the error message that I am getting:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /public_html/browse.php on line 130

I removed the @ symbols, but it has not resulted in any additional error messages.

CFMaBiSmAd
08-24-2007, 04:36 AM
So, re-read my post because you only did one small part of what was suggested, read the information at the link I posted, add some error checking logic to the mysql_query() function call, and then tell us what you get.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum