Can't query database

Discussion in 'PHP' started by MichaelLewis, Apr 3, 2008.

  1. #1
    I have a database with a table called "testtbl" and a field called "UserID".
    I have entered data in this table (54 rows) but I can't extract and print the data. I don't get any error messages either.

    Can you tell me what's wrong with my code?

    mysql_connect(localhost,$username);
    mysql_select_db($database) or die ("Unable to select the database.");
    $query = "SELECT UserID FROM testtbl";
    $Results = mysql_db_query($database,$query);
    mysql_close();
    print("$Results<br>");

    Thanks,
    Michael
     
    MichaelLewis, Apr 3, 2008 IP
  2. goldensea80

    goldensea80 Well-Known Member

    Messages:
    422
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    #2
    First, your mysql connection does not seem good
    Second, you cannot print the $Result directly by that way,
    Try this:
     
    goldensea80, Apr 3, 2008 IP