Results 1 to 2 of 2

Thread: warning on myqsl_fetch_array

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    warning on myqsl_fetch_array

    When I conduct a query within a query I get the following warning on myqsl_fetch_array.

    I make my first search into one db table. Then taking the result I search the 2nd table, as you see 2 added next to the 2nd search on $con2, $sql2...

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ....php on line 36
    PHP Code:
    <?php
    $bookTitle 
    "";
    //echo "<span style='font-weight: bold; font-family: Verdana, Times New Roman, serif; font-size: 24px;'>".$bookTitle."</span><br /><br />\n";
    $con mysql_connect("","root","");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }
    mysql_select_db("boti_book"$con);
    $i $_GET['page_num'];
    //$keyword = "membership lists";
    $sql "SELECT * FROM boti_css WHERE fontweight LIKE '%bold%'";
    $result mysql_query($sql);
    //echo $sql;
    while($row mysql_fetch_array($result))
    {
        echo 
    "<span";
        echo 
    " style='font-weight: bold;' ";
        echo 
    "><a href='index.php?page_num=".$row['page_num']."' style='text-decoration: none; color: black;'";
    ?>
    onMouseOver='this.style.color="red"; this.style.textDecoration="underline";' onMouseOut='this.style.color="black"; this.style.textDecoration="none";'
    <?php    
        
    echo ">";
        
    $searchPage $row['page_num'].
        
    $con2 mysql_connect("","root","");
        if (!
    $con2)
          {
          die(
    'Could not connect: ' mysql_error());
          }
        
    mysql_select_db("boti_book"$con2);
        
    $i $_GET['page_num'];
        
    //$keyword = "membership lists";
        
    $sql2 "SELECT * FROM boti_pages WHERE page_num = ".$searchPage;
        
    $result2 mysql_query($sql2);// or die(mysql_error());
        //echo $sql;
        
    while($row2 mysql_fetch_array($result2))
        {
        echo 
    $row2['content'];
        echo 
    " Page ".$row2['page_num']."</a></span><br /><br />\n";
        }
        
    //mysql_close($con2);    
    }
    mysql_close($con);
    ?>
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: warning on myqsl_fetch_array

    Check if the query has executed successfully before using the result set.

Posting Permissions

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



Click Here to Expand Forum to Full Width