Kev30
Kev30

Reputation: 119

Wrong numbers in mysql

I want to enter my XP in mysql. Now is the xp with a , so i removed them with a small script. Now i want to enter them in mysql and this is what i get : Overallxpnow = 8388607

Now the problem is my xp is 328,147,065. So it's is not right. I entered a echo with the variable that is used to get it in mysql and it shows the 328 xp amount (the correct one). The problem is that i really have no idea why it is showing me the wrong number.

This is the script :

$result = mysql_query("SELECT * FROM track WHERE  `rsname` ='$name'");

if( mysql_num_rows($result) > 0) {
    mysql_query("UPDATE  track SET 
    `rsname` = '$name',
    `overallranknow` = '$Overalln', 
    `overalllevelnow` = '$Overall[1]',
    `overallxp` = '$Overalln2' WHERE 
    `rsname` = '$name', 
    `overallranknow` = '$Overalln', 
    `overalllevelnow` = '$Overall[1]'
    `overallxpnow` = '$Overall2'");
}
else
{
    mysql_query("INSERT INTO track (`rsname`, `overallranknow`, `overalllevelnow`, `overallxpnow` ) VALUES ('$name', '$Overalln', '$Overall[1]', '$Overall2')");

}   
}     

This is the code to remove the ,

$value2= $Overall[2]; 
$bad_symbols2 = array(",", "."); 
$Overall2 = str_replace($bad_symbols2, "", $value2);

I hope i told as mutch info as i can.

Also i'm using mediumint as tabel type.

~Kev (bad english = sorry)

Upvotes: 0

Views: 212

Answers (1)

Bart Friederichs
Bart Friederichs

Reputation: 33491

You are using the wrong field type. The documentation says MEDIUMINT has a range of -8388608 to 8388607.

Upvotes: 2

Related Questions