www.webdeveloper.com
Results 1 to 2 of 2

Thread: Mysql sorting

  1. #1
    Join Date
    Oct 2006
    Posts
    6

    Mysql sorting

    PHP Code:
    <?php
    $con 
    mysql_connect("localhost""username""password");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("sjpayme_search"$con);

    $result mysql_query("SELECT * FROM search WHERE type='web' DESC");

    while(
    $row mysql_fetch_array($result))
      {
      echo 
    $row[query];
      }

    mysql_close($con);
    ?>
    it show me this:
    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /public_html/main/xyz.php on line 18
    what is the problem?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,220
    The error message means your query was not able to be processed by MySQL, so it returned boolean false instead of a resource ID. I suspect the error is the "DESC" without an "ORDER BY field_name" before it. You can make it easier to debug by using this coding pattern:
    PHP Code:
    $sql "SELECT * FROM search WHERE type='web' DESC";
    $result mysql_query($sql) or die("Query failed: $sql - " mysql_error()); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles