A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: PHP question - Database values are always zero...

  1. #1
    Moderator CNO's Avatar
    Join Date
    Jun 2000
    Location
    Brooklyn, NY
    Posts
    3,446

    PHP question - Database values are always zero...

    I'm posting this on behalf of MarkP, who is having trouble accessing Flashkit.

    PHP Code:
    <?php 
    $server 
    "localhost"
    $username "me"
    $database "db";
    $table "tutorial_user_auth";
    $password "pass";
    print 
    "High Score<BR>"
    mysql_connect($server,$username,$password); 
    @
    mysql_select_db($database) or die( "Unable to select database "); 
    $query="SELECT * FROM $table ORDER BY HighScore DESC"
    //$result=mysql_query($query); 
    $result=mysql_query($query) or die( "query failed");
     
    $i 0
    while (
    $i 10

    $username mysql_result($result,$i,"userName");   
    $highscore mysql_result($result,$i,"HighScore");   
    print (
    "<b>" $username "</b> Score: " $highscore "<BR>");  
    ++
    $i
    }
    ?>
    This seems to work, but the score values (HighScore) are always returned as 0 (zero). The names are got from the database correctly... but the scores are always zero!!!!

    Its getting the names and ordering them by their userID, the key field in the database.

    Is this because I added the scores in to the database manually?

    It shouldn't be, should it?

  2. #2
    Junior Member
    Join Date
    May 2002
    Posts
    5
    What is the field type?

  3. #3
    Moonlight shadow asheep_uk's Avatar
    Join Date
    Dec 2001
    Location
    London
    Posts
    2,010
    What happens if you remove all the $i variables?

  4. #4
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Var type used to be bigint... but I changed it and its now just a varchar... I'll try to remove the $I variable and see what happens

  5. #5
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Are you sure you got the variable name for HighScore right?

    I notice userName has a a lower case u but HighScore has an upper case H???

    Also check that the variable is being entered into the database correctly? With Db programming I usually check the data first coding second. You kick yourself when you spend hours debugging code to find it is somewhere completely different that is not entering the data correctly.
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  6. #6
    Phantom Flasher... Markp.com's Avatar
    Join Date
    May 2000
    Posts
    16,034
    Originally posted by tupps
    Are you sure you got the variable name for HighScore right?

    I notice userName has a a lower case u but HighScore has an upper case H???

    Also check that the variable is being entered into the database correctly? With Db programming I usually check the data first coding second. You kick yourself when you spend hours debugging code to find it is somewhere completely different that is not entering the data correctly.
    Yes it is HighScore... The data is there in phpmyadmin... I still don't see why it doesn't 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center