Re: Strange DB Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



                                                                                                                                       
                                                                                                                                       
                                                                                                                                       








>Error trapping is not really relevant here as the server is properly
configured so the errors are going to show up in either event. In fact,
using the die() >function on my server just makes thing worse.

---
it'll definitely make it worse, but hopefully only to find the problem and
make it better.  you should be able to find the query on which this is not
a     valid resource run that agains't mysql and find out why its failing,
if you can't see that from $qry being in die().  but yes, a bad idea in
production.       send the output to a file on error and see what your
getting.the error that you want is from mysql_query, the error that you're
showing is from mysql_fetch_array(), so if the server is configured to show
them elsewhere then the answer should be right before the error below


hth
jeff


In any case, the var_dump was a good idea as I was able to find out that
what is happening is when this loops up after the first run through the
array is blank. It doesn't reinitialize the array with the new values. As
far as the $cat, or any of the other variables go, they're always the same
when returning to he index. Whether I initialize them from the query
string, or in the index itself as in the case when it is loaded without any
parameters. The question is, why wouldn't the array be redefined on the
second loop? Hell if I know.

Nick

jeffrey_n_Dyke@xxxxxxxxx wrote:





            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.
      <psedocode>
      $qry = "SELECT * FROM categories WHERE length(cat)='2'";
      $s = mysql_query($qry) or die (mysql_error() . "\n"<br>" . $qry .
      "\n<br>");
      <psedocode>


      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.

      HTH
      Jeff


            $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
            href=\"index.php?index=directory.inc&cat=$cat&name=$name&depth=0\">$name</a></b></font>";




               $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

      serif,helvetica\"

            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
            appreciated.



            Nick

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux