-
Moderator
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?
-
-
Moonlight shadow
What happens if you remove all the $i variables?
-
Phantom Flasher...
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
-
Senior Member
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.
-
Phantom Flasher...
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|