Page 1 of 1

Weird Error from Outputted Results

Posted: Sat Dec 23, 2006 10:10 am
by nickman013
Hello,

I have a code that makes a voting system, and when a user votes, the number goes up +1 in the database under the "top5votes" field in my database..

I have a page that outputs whos in the lead, and how many votes they have... But I am getting a problem, the person in the lead has a 2 digit number of votes, like 12, 24, 49, or w/e. It puts them at the bottom of the list and everyone else in good order from the most to least votes...

My code is

Code: Select all

<?
$username2= "muot_report";  
$password2= "passswr";  
$database2= "muot_report";  
$connection2 = mysql_connect('localhost',$username2,$password2);  
mysql_select_db($database2); 
$sql4 = "SELECT * FROM `report` WHERE top5 =1 ORDER BY `top5votes` DESC";
$result = mysql_query($sql4) or die(mysql_error()); 
while($row = mysql_fetch_array($result)) { 
echo "<tr class=odd><td align=center>".$row['prevname']."</td><td align=center>".$row['top5votes']."</td></tr>";
}
?>

Posted: Sat Dec 23, 2006 10:48 am
by Ambush Commander
What likely is happening is top5votes is not an integer but vartext column, causing MySQLs interesting collation. Can you give us the db schema?

Posted: Sat Dec 23, 2006 11:19 am
by nickman013
That was it.. THANKS SO MUCH
the problem was that I had top5votes as char and not int..

Thanks SOO MUCH!!!!