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 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem didplaying MySQL data

    I am trying to make a script that will disply a users points (bits), but it always shows up as 1 when the number in the database is something else. Here is my 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(sparky_data)
    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 print_r($qry);
    echo 
    "<br>Bits: <a href='bits.php'>$get_info</a>";
    ?>

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    England
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    echo "<br>Bits: <a href='bits.php'>$get_info</a>"
    There's where your problem is at. It's better to do it like this:

    PHP Code:
    echo '<br>Bits: <a href="bits.php">' $get_info '</a>'
    Now try that

    EDIT: That's if you are trying to get the output from the $get_info variable to display between the anchor tags i hope. Otherwise i'm making myself look stupid

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    trying to echo the query? tsk tsk...lol
    you have to add this ...

    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(sparky_data)
    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());  
    while(
    $row mysql_fetch_assoc($qry)){
    $get_info $row[bits];
    }
    echo 
    "<br>Bits: <a href='bits.php'>$get_info</a>";
    ?>
    I'm pretty sure that will work...the $row[bits] part mite be wrong cuz idk what row you want to grab...good luck

  • #4
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Let me see if this will work...


  •  

    Posting Permissions

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