Web Analytics Made Easy -
StatCounter Suddenly a script no longer works - CodingForum

Announcement

Collapse
No announcement yet.

Suddenly a script no longer works

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Suddenly a script no longer works

    Hallo,

    I always get the following message when starting a search in my
    database:

    Search for titles in the mylibrary database
    Search for titles beginning with a:
    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in d:\programme\apache group\apache\htdocs\bibli\find.php on line 230



    --------------------------------------------------------------------------------


    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in d:\programme\apache group\apache\htdocs\bibli\find.php on line 245

    Back to search form.


    Do you have an idea what the reason for this message could be?

    Yours sincerelly,

    Matthias

  • #2
    Welcome here !

    Yes. That you entered the wrong resultID inthere or that the select didn't return any records.

    Without you posting the code from the selectquery till row 230, there is nothing sensible we can say about it.

    It should look like
    PHP Code:
    $select="select ...";
    $result=mysql_query($select,$link) or die (Query problem);
    if (
    mysql_num_rows($result) >= 1){
         while(
    $row=mysql_fetch_object($result)){
    ...
         }

    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment


    • #3
      Here is the code

      Ok, here is my code. The strange thing is that it has been
      working for a long time. No the system administrator
      changed the internal page name and I get this Problem.


      PHP Code:
        $result1 mysql_query or die(mysql_error());

              (
      "SELECT titles.titleID AS titleID, " .
               
      "       titles.title AS title, " .
               
      "       titles.subtitle AS subtitle, " .
               
      "       titles.edition AS edition, " .
               
      "       titles.year, " .
               
      "       titles.isbn, " .
               
      "       titles.comment, " .
               
      "       publishers.publName AS publisher, " .
               
      "       publishers.publID, " .
               
      "       categories.catName AS category, " .
               
      "       languages.langName AS language " .
               
      "FROM titles JOIN tmpTitleIDs" .
               
      "     LEFT JOIN categories ON titles.catID = categories.catID " .
               
      "     LEFT JOIN languages ON titles.langID = languages.langID " .
               
      "     LEFT JOIN publishers ON titles.publID = publishers.publID " .
               
      "WHERE titles.titleID = tmpTitleIDs.titleID");

            
      // query for authors
            
      $result2 mysql_query
              
      ("SELECT tmpTitleIDs.titleID, rel_title_author.authID, " .
               
      "       authName AS author " .
               
      "FROM authors, rel_title_author, tmpTitleIDs " .
               
      "WHERE authors.authID = rel_title_author.authID " .
               
      "  AND rel_title_author.titleID = tmpTitleIDs.titleID " .
               
      "ORDER BY rel_title_author.authNr, authName");

            
      // copy authors into array
            
      while($row mysql_fetch_object($result2)) {(error nr 1)
              
      // seperate authors by a comma
              
      if($authors[$row->titleID]) 
                
      $authors[$row->titleID] .= ", ";
              
      // add author to author's list; because of ORDER BY clause
              // in the SQL statement the authors are ordered correctly
              
      $tmp build_href("./find.php"
                                
      "sqlType=title&authID=$row->authID"
                                
      last_name_last($row->author));
              
      $authors[$row->titleID] .= $tmp;
            }

         
      // show title list
            
      echo "<hr><ul>\n";
            
      $titlecount=0;
            while(
      $row mysql_fetch_object($result1)) {(error 2)
              
      $titlecount++;
              if(
      $titlecount<=$pagesize) {
                if(
      $row->publisher)
                  
      $publref build_href("./find.php"
                                        
      "sqlType=title&publID=$row->publID"
                                        
      $row->publisher); 
      I tried with the ...or die but I get no new error message

      Thanx,

      Norok

      Comment


      • #4
        Error n°1 is probably because there are no records returned (which is not unlikely in a three table join). Because the resourceID is set corectly.

        So check to see ig there arerecords returned, before exectuing the loop with the mysql_nu_rows (see my previous post)

        Error n°2 is because there is no query executed. I'm realy surprised that the parsing doesn't stop at the very first line that you printed. You best store the query in a variable and then ececute it like i posted in my previous post.
        But i think that if you execute tha first query, that you will get en error on the 'JOIN' ... It also doesn't look like a realy performant query, with these 3 outer joints + 2 inner joins that you have there...
        Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

        Comment


        • #5
          How to get records?

          Hallo and thanx first,

          but I ve never run the script while getting records. How can I get them?
          2nd: I always "execute" the queries like above, what do you mean that dont
          execute them?


          Norok

          Comment


          • #6
            Re: How to get records?

            Originally posted by Norok
            but I ve never run the script while getting records. How can I get them?
            What i mean is : there are probably no records that meet the conditions from your where clause.

            Try executing the query in phpmyadmin or anothr db frontend, and see if it eturns any records.

            If it dosn't then your query is pointless because there is no data that meets your condition so nothing will happen. You then either need more/other data inside your db, or change your query

            Originally posted by Norok
            2nd: I always "execute" the queries like above, what do you mean that dont execute them?
            Well, exactly what i said : they are not executed.
            mysql_query ("select var from table");
            will execute the query select var from table.

            $sql = "select var from table" ;
            $result = mysql_query($sql);

            will also execute the same query.

            But
            $sql = "select var from table" ;
            $result = mysql_query();

            or

            $result = mysql_query($sql);
            $sql = "select var from table" ;

            or

            $result = mysql_query();
            "select var from table" ;

            wount do anything (except probably throwig an error)
            i'd realy suspect that this would throw an error:
            $result1 = mysql_query or die(mysql_error());

            ("SELECT titles.titleID AS titleID, " .
            ....
            Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

            Comment

            Working...
            X