warning on myqsl_fetch_array

Discussion in 'PHP' started by gilgalbiblewheel, Apr 29, 2008.

  1. #1
    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...

    <?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);
    ?>
    PHP:

     
    gilgalbiblewheel, Apr 29, 2008 IP
  2. BigJim21

    BigJim21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $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;
    this looks like the right line
        while($row2 = mysql_fetch_array($result2))
    PHP:
    ok so from what i see your problem is with $searchPage = $row['page_num'].
    how are you getting $row['page_num'] when you have row set to something with css and $i = $_GET['page_num'];
    as the place to get the page num from anyway i dont know what you got in that part of the db but i think you just got that little typeo also have a link with the $row['page_num'] thing too does it work for you
     
    BigJim21, Apr 29, 2008 IP