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

    What's wrong with my code?

    I am trying to make a script that will display a persons points (bits) according to a username cookie, I've made a code, but I don't know what is wrong with it, it keeps coming up as errors. Here is the 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 username FROM users WHERE username=$cookie);
    or die ("Could not get data because ".mysql_error());
    $get_info = mysql_fetch_row($qry);
    ?>

    I would really like it if someone could tell me what is wrong with it. Thanks!

  • #2
    New Coder
    Join Date
    Aug 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would also be nice to know how to get it to show up too. Like with an echo or print function.

  • #3
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    845
    Thanks
    15
    Thanked 10 Times in 10 Posts
    Can I ask you the next time please put your code in [ php ] tags... so that way it is highlighted and easier to read.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #4
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    PHP Code:
    $qry mysql_query("SELECT username FROM users WHERE username = $cookie") or die ("Could not get data because " mysql_error()); 
    Quotes added around query string and semi-colon removed from after call to mysql_query.


  •  

    Posting Permissions

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