Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Help displaying MySQL data

    Okay, I just don't know what is wrong. Here is the code:
    PHP Code:
    <?php
    include("config.php"); 
    // connect to the mysql server
    $link mysql_connect($server$db_user$db_pass)
    or die (
    "Could not connect to mysql because ".mysql_error());
    // select the database
    mysql_select_db($database)
    or die (
    "Could not select database because ".mysql_error());
    $cookie $HTTP_COOKIE_VARS["starbits_username"];
    $qry mysql_query("SELECT bits FROM users WHERE username = $cookie") or die ("Could not get data because " mysql_error());  
    $get_info mysql_fetch_row($qry);
    ?>
    It keeps coming out as this error:
    Could not get data because Unknown column 'test' in 'where clause'

    I have looked it over hundreds of times, could someone help me?

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    in your WHERE statement, try enclosing $cookie with single quotes.

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now all I get is a blank screen.

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You would do. You're not printing anything out to the screen. You need to add something like

    echo $get_info[0];

    at the end of your script

  • #5
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ha ha ha I'm so silly! Thanks for your help everyone!

  • #6
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now all it says is "Array"! I am so confused.

  • #7
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    to print out an array use print_r().
    To print out any variables in human-readable form use var_dump().

  • #8
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by marek_mar
    to print out an array use print_r().
    To print out any variables in human-readable form use var_dump().
    print_r can print out anyyhing in human readable format. (I think.) According to php.net var_dump only show shows public properties of objects wheras print_r shows it all.

  • #9
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Oh yes you are right. print_r shows the values and var_dump shows the types.
    EDIT var_dump() showsd the type and the value and print_r() only the value.
    Last edited by marek_mar; 10-03-2004 at 12:39 PM.

  • #10
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now it displays

    Resource id #5
    Bits: 1

    The bits is supposed to be 1500, and how do I get rid of Resource id #5?

  • #11
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is confusing


  •  

    Posting Permissions

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