Miren tengo un problema y es que en un campo de a base de datos llamado Drive me modifica el valor a 10 cincos. Tengo muchas dudas como,
1)si tengo en la BD Int 3 como me aparece 10 numeros.
2)Me funciona en todos el code menos con este campo
3)No me lo modifica y elimine y lo vuelvo a Crear pero es lo mismo
Aca el code
Código PHP:
function entrenamiento()
{
$id=$_SESSION['valid_id'];
$db=db_connect();
$query = "select * from user where id='$id'" or die (mysql_error());
$resultado = mysql_query($query,$db);
$row=mysql_fetch_array($resultado);
if ($row["ent_1"]=="drive")
{
if ($row["drive"]<=20)
{
$agregar1=rand(7,9);
}
elseif ($row["drive"]<=35 && $row["drive"]>20)
{
$agregar1=rand(6,8);
}
elseif ($row["drive"]<=50 && $row["drive"]>35)
{
$agregar1=rand(5,7);
}
elseif ($row["drive"]<=75 && $row["drive"]>50)
{
$agregar1=rand(4,6);
}
elseif ($row["drive"]<=80 && $row["drive"]>75)
{
$agregar1=rand(3,5);
}
elseif ($row["drive"]<=90 && $row["drive"]>80)
{
$agregar1=rand(2,3);
}
elseif ($row["drive"]<=100 && $row["drive"]>90)
{
$agregar1=rand(1,2);
}
elseif ($row["drive"]>=100)
{
$agregar1=rand(-2,-8);
}
else
{
$agregar1=rand(10,11);
}
$agregar=$agregar1;
$query="UPDATE juego.user SET drive ='$agregar' WHERE user.id=$id";
$resultado = mysql_query($query,$db) or die (mysql_error());
}
elseif ($row["ent_1"]=="reves")
{
if ($row["reves"]<=20)
{
$agregar1=rand(7,9);
}
elseif ($row["reves"]<=35 && $row["reves"]>20)
{
$agregar1=rand(6,8);
}
elseif ($row["reves"]<=50 && $row["reves"]>35)
{
$agregar1=rand(5,7);
}
elseif ($row["reves"]<=75 && $row["reves"]>50)
{
$agregar1=rand(4,6);
}
elseif ($row["reves"]<=80 && $row["reves"]>75)
{
$agregar1=rand(3,5);
}
elseif ($row["reves"]<=90 && $row["reves"]>80)
{
$agregar1=rand(2,3);
}
elseif ($row["reves"]<=100 && $row["reves"]>90)
{
$agregar1=rand(1,2);
}
elseif ($row["reves"]>100)
{
$agregar1=rand(-2,-8);
}
else
{
$agregar1=rand(10,11);
}
$agregar=$agregar1+$row["reves"];
$query="UPDATE juego.user SET reves ='$agregar' WHERE user.id='$id'";
$resultado = mysql_query($query,$db) or die (mysql_error());
}
}
Ahora talvez me explique mejor en el campo ent_1 se guarda el enttrenamiento que puede ser drive reves voleas,etc,etc.
En el code loque hace es aumentar el entrenamiento segun lo que tengas. Bueno en la base de datos to pongo
Drive 20
Reves 25
Cuando modifico en reves se cumple aumentando en 3,5,7,9,etc
pero en el drive me aperece 5555555555 es decir 10 cincos, Ponga lo que ponga me aparece 10 cincos. Entonces dije talvez si poongo el numero mas grande me lo tome, pero no sigue modificandose a 10 cincos. Bue como antes dije lo mas raro es que es
int (3) es decir que solo toma hasta 3 digitos pero no se porque me aparece 10 digitos
Ayuda!!!!!!!