php biginner here : Warning: mysql_fetch_array(): !!!

Discussion in 'PHP' started by suvidha.writer, Oct 20, 2010.

  1. #1
    <?php
    $ssresult = mysql_query("SELECT * FROM gm_special order by w_date desc");

    while($result_row= mysql_fetch_array($ssresult)){

    $date=$result_row['w_number'];

    $ss1= mysql_query("SELECT * FROM tablename WHERE cat='category_1' AND w_number = '$date' ");
    $ss_1=mysql_fetch_array($ss1);

    $ss2= mysql_query("SELECT * FROM tablename WHERE cat='category_2' and w_number = '$date' ");
    $ss2_1=mysql_fetch_array($ss2);
    }

    ?>


    why showing error ?? can i use mysql_fetch_array under another mysql_fetch_array???
     
    suvidha.writer, Oct 20, 2010 IP
  2. mephisto73

    mephisto73 Greenhorn

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    $ss1 or $ss2 might be empty and therefore mysql_fetch_array returns an error. Try checking the variable before running through mysql_fetch_array.

    Just a suggestion.
     
    mephisto73, Oct 20, 2010 IP
  3. xpertdev

    xpertdev Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First of all check the value of the $date do you receive this value proper or not.
    If yes then have practice to make your query like below:
    $ss1= mysql_query("SELECT * FROM tablename WHERE cat='".category_1."' AND w_number = '".$date."'");
    I think you might try this and let me know.
    Hope this helps
    Avi
     
    xpertdev, Oct 20, 2010 IP
  4. suvidha.writer

    suvidha.writer Active Member

    Messages:
    75
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    still error ... :(

    there have value ..but what is the problem??
     
    suvidha.writer, Oct 20, 2010 IP
  5. max2010

    max2010 Greenhorn

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    of course be sure that the table "tablename" is there in db, and there's a "category_1" field
    syntax should be like this:

    $ss1= mysql_query("SELECT * FROM `tablename` WHERE `cat`='category_1' AND `w_number`='".$date."';");

    also, are you sure that you are fetching the right field:
    $date=$result_row['w_number']; ???

    or maybe:
    $date=$result_row['w_date']; ?
     
    max2010, Oct 21, 2010 IP