>When returning to the main page of my script sometimes I'll get the
>following error:

>Warning: mysql_fetch_array(): 8 is not a valid MySQL result resource in
>/home/nick/http/search/includes/main.inc on line 13

>This happens only AFTER the first element in the resource has been
>processed. Here's the code that is causing the problem:

First, i'd place an... or die (mysql_error()) after your mysql call.  so
you can see what mysql is complaining about.  basically your sql is
failing.  I also like to split the first two items, when debegging, to see
what the actual query was.  i.e.
$qry = "SELECT * FROM categories WHERE length(cat)='2'";
$s = mysql_query($qry) or die (mysql_error() . "\n"<br>" . $qry .

The only time i saw the error on your page the 'cat' GET variable was
defined as 0.  Is this really a static query like below, or is it based on
what is passed to the page in the query string?  The URL when it died...
http://www.icesource.com/index.php?depth=0&cat=0&index=main.inc, which to
me looks like a bad querystring, but may indeed be valid values.

If that doesn't lend itself to any useful information, try var_dump($t); in
your while loop, to see what has been processed and what is failing.


>$s = mysql_query("SELECT * FROM categories WHERE length(cat)='2'");
>while($t = mysql_fetch_array($s)){>    $cat = $t["cat"];
>    $name = $t["name"];
>    if($tstruc == $dirwidth){>        echo "</tr><tr>";
>        $tstruc = 0;
>    }
>    echo "<td align=\"left\" valign=\"top\"><font face=\"verdana,sans
>serif,helvetica\" size=\"3\"><b><a

>    $subcat = mysql_unbuffered_query("SELECT * FROM categories WHERE
>length(cat)='4' && substring(cat,1,2)='$cat' ORDER BY cat");
>    while($ct = mysql_fetch_array($subcat)){>        $scats
= $ct["name"];
>        $dcats = $dcats . $scats . ", " ;
>    }
>    $dcats = trim(substr($dcats, 0, 28)) . trim("...");
>    if($dcats != "..."){>        echo "<br><font face = \"tahoma,sans
>size=\"1\">" . $dcats . "</font>";
>    }
>    $dcats = "";
>    echo "</td>";
>    ++$tstruc;

>You can go to the site http://www.icesource.com to see this script in
>action. This is an intermittent problem so you may not see it at the
>site, but it does happen there sometimes. If you click on one of the
>categories on the list there, and to two or three deep, then hit the
>Home link at the top left of the listings there's a pretty good chance
>you'll see the problem. I've been trying to figure this out for a long
>time, and nothing seems to work. Any ideas out there would be greatly


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to