SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Location
    Screw City
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello...
    Earlier I created a simple song download tracker for my site. Now I want to display the statistics on a page, to relieve the hassles of logging onto my host's phpMyAdmin, and to allow my bandmate to see these results as well. However, I'm finding it quite impossible to properly query the database for the specific information I'm looking to display -- namely, the number of hits a certain song has acquired...
    Now, I assume this ought to be a simple task. Simply select the value from the hits column where a specific song is in the songID column, assign it to a variable, and echo that variable to the page. But all I get printed from that variable is "Reference ID#" and a digit, significant of something unknown to me. My assumption is it means nothing has been assigned to this particular variable. Anyone have any ideas?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    share your code with us so someone will help you instead of guessing what your code is

  3. #3
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code you should be using:
    PHP Code:
    $cnx mysql_connect("localhost""dbusername""dbpassword") or die ("Unable to connect to database server.");
    mysql_select_db("databasename"$cnx) or die("Unable to select database.");
    $sql "SELECT hits FROM songs WHERE songID = '$id'";
    $result mysql_query($sql);
    $row mysql_fetch_array($result);
    $hits $row["hits"];

    echo 
    "Number of hits: $hits<p>"
    You should change this code to reflect your database table structure and login details.


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
  •