SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help find errors in my Query

    Just wondering what I am doing wrong here.

    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ax3/public_html/admin/t50.php on line 20

    Code:
    <?php
    $DB_SERVER = "localhost";
    $DB_SERVER_USERNAME = "my_username";
    $DB_SERVER_PASSWORD = "password";
    $DB_DATABASE = "my_database";
    $Token_Table= "the_table";
    
    
    $link = mysql_connect($DB_SERVER,$DB_SERVER_USERNAME,$DB_SERVER_PASSWORD);
    
    mysql_select_db($DB_DATABASE,$link);
    
    print("<TABLE BORDER =1 WIDTH =\"95%\" CELLSPACING = 2 CELLPADDING = 2 ALIGN =CENTER > \n ");
    print("<TD ALIGN = CENTER VALIGN = TOP >Purchase Id</TD> ");
    print("<TD ALIGN = CENTER VALIGN = TOP >Customer Id</TD>");
    print("<TD ALIGN = CENTER VALIGN = TOP >Tokens Purchased</TD>");
    print("<TD ALIGN = CENTER VALIGN = TOP >Ip</TD>");  
      $qry = mysql_query ( "SELECT tpurchased_id, customer_id, tokens_purchased, ip FROM $Token_Table WHERE tokens_purchased = '150'" );
    
        while ( $rst = mysql_fetch_array ( $qry ) ) {
    
         print("<TD ALIGN = CENTER VALIGN = TOP >['tpurchased_id']</TD>");
         print("<TD ALIGN = CENTER VALIGN = TOP >['customer_id']</TD>");
         print("<TD ALIGN = CENTER VALIGN = TOP >['tokens_purchased']</TD>");
         print("<TD ALIGN = CENTER VALIGN = TOP >['ip']</TD>");
    
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    this might be it

    WHERE tokens_purchased = '150'
    If the datatype of your tokens_purchased column is an int or some other number, leave out the quotes so it would be...
    tokens_purchased = 150

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, there appears not to be a record set. You can trap for it like this:

    Code:
    if(mysql_fetch_array($qry)) {
      //put your loop here
    }


Bookmarks

Posting Permissions

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