Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    Maryland, USA
    Posts
    165
    Thanks
    12
    Thanked 0 Times in 0 Posts

    resource goes missing after login

    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:
    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)
    Last edited by madmatter23; 08-24-2007 at 04:03 AM. Reason: clarification

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    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
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    Maryland, USA
    Posts
    165
    Thanks
    12
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    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.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •