I have this little tid-bit of my code, which is eventually sent to a MySQL database. The rest of the code is sound, but this code likes to give me empty data some of the time. Is there any way to prevent this from happening?
Edit: Here's the whole chunk
//random Species
$sp_one = mt_rand(1,10);
$one_species = "Water Leaper";
//random Genetics
if($one_species == "Water Leaper")
{
$one_gene = mt_rand(1,5);
if($one_gene < 3)
{
$one_genetics = "1";
}
else if($one_gene < 5)
{
$one_genetics = "2";
}
else
{
$one_genetics = "3";
}
}
//random Gender
$one_sex_num = mt_rand(1,2);
if($one_sex_num == 1)
{
$one_gender = "Female";
}
if($one_sex_num == 2)
{
$one_gender = "Male";
}
//Entering it
$sql="INSERT INTO creatures (species, sex, location, genetics)
VALUES('{$one_species}','{$one_gender}', 's1','{$one_genetics}')";
mysqli_query($con,$sql);