mysql query question

Discussion in 'MySQL' started by trixs, Jul 15, 2007.

  1. #1
    Hello All!

    I am having a lil problem when it comes to retrieving data for a specific query.

    I am working on a pagination class and some reason this query does not wish to work for me.

    A code snippet

    $query = "SELECT COUNT(*) FROM $query";

    $result = mysqli_query($cxn, $query)
    or die ("couldnt execute query");

    $query_data = mysql_fetch_row($result);
    $numrows = $query_data[0];

    I just want to find the number of rows from the count
    It gives me this error no matter how I change it --

    mysql_fetch_row(): supplied argument is not a valid MySQL result resource in...
     
    trixs, Jul 15, 2007 IP
  2. trixs

    trixs Peon

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Fixed my own problem - This might be helpfull to anyone that is newer-- Make sure your using the correct msql query!!


    $query = "SELECT COUNT(*) FROM $query";

    $result = mysqli_query($cxn, $query)
    or die ("couldnt execute query");

    $query_data = mysqli_fetch_row($result);
    $numrows = $query_data[0];

    I just want to find the number of rows from the count
    It gives me this error no matter how I change it --
     
    trixs, Jul 15, 2007 IP
  3. technoguy

    technoguy Notable Member

    Messages:
    4,369
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    205
    #3
    $query = "SELECT COUNT(*) FROM $query"; according to me this is a very strange statement.
     
    technoguy, Jul 15, 2007 IP