problem

Discussion in 'PHP' started by mahiraj, Nov 27, 2007.

  1. #1
    Hi all,

    I am facing this problem pleasel help me


    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\wamp\www\dialedge\show.php on line 48
     
    mahiraj, Nov 27, 2007 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check that your query is valid and that your are conencted to your database.
     
    matthewrobertbell, Nov 27, 2007 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    Submit code for line 45 to 49 so we can get clear view of this Warning
     
    greatlogix, Nov 27, 2007 IP
  4. mahiraj

    mahiraj Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    my code is

    <?php
    $dt=$_REQUEST['date'];
    $dt2=$_REQUEST['date2'];
    $st=$_REQUEST['status'];

    $select_val=$_POST['select_val'];
    echo $val_count=count($select_val);
    $qry="";
    for($i=0;$i<=$val_count;$i++)
    {
    if($qry=="")
    $qry = $select_val[$i];
    else
    $qry .= "," .$select_val[$i];
    }

    if ($st=="all")
    {
    echo $rs=mysql_query("SELECT $qry FROM dialedge_list left join dialedge_log on dialedge_list.phone_number=dialedge_log.phone_number where dialedge_log.call_date >='$dt' and dialedge_log.call_date <= '$dt2'");
    }
    else
    {
    echo $rs = mysql_query("SELECT $qry FROM dialedge_list left join dialedge_log on dialedge_list.phone_number=dialedge_log.phone_number where dialedge_log.call_date >='$dt' and dialedge_log.call_date <= '$dt2' and dialedge_log.status='$st'");
    }
    if(mysql_num_rows($rs)>0)
    //if(mysql_fetch_array($rs))
    {
    //echo "<a href='excell.php?id=$st'>Download excell format</a>";
    echo "<table width='98%' border='0' cellpadding='5' cellspacing='2' class='tab-bg' >";
    $rt =explode(',' ,$qry);
    for($j=0;$j<$val_count;$j++)
    {
    echo "<th bgcolor='#E7E7E7'><span class='font'>".$rt[$j]."</span></th>";
    }
    while($row=mysql_fetch_array($rs))
    {
    echo "<tr>";
    for($k=0;$k<$j;$k++)
    {
    echo "<td bgcolor='#E7E7E7' ><span class='font1'>".$row[$k]."</span></td>";
    }
    echo "</tr>";
    }
    echo "</table>";
    }

    else
    {
    echo "<b>"."<font size=3 color=#CC0000 face=Verdana>"."No Matching Records..................."."</font>"."</b>"."<br>";
    ?><input type="button" value="<< Back to Search" onclick="self.location='index.php'">
    <?php }
    mysql_close($con);
    ?>
     
    mahiraj, Nov 27, 2007 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Change all occurrences of:

    mysql_query("QUERY");

    to

    mysql_query("QUERY") or die ();

    And give us the error.

    Peace,
     
    Barti1987, Nov 27, 2007 IP
  6. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Don't you mean:

    mysql_query("QUERY") or die (mysql_error());

    ?
     
    MMJ, Nov 27, 2007 IP