Jump to content

Some variables work, some don't


rhijaen

Recommended Posts

Mostly the $b_r_* and $b_p_* don't evaluate to true when comparing them to 0 even though they are 0 in the mysql db. They are varchar(50) in the mysql db.

 

They aren't evaluating to true so they don't get printed.

 

I tried (!empty($b_r_air)) and that is true but it prints nothing..what's wrong?

 

while($newArray = mysql_fetch_array($result)){
$b_attack[$count] = $newArray['b_attack'];
$b_dodge[$count] = $newArray['b_dodge'];
$b_damage[$count] = $newarray['b_damage'];
$b_radiance[$count] = $newarray['b_radiance'];
$b_r_air[$count] = $newarray['b_r_air'];
$b_r_dark[$count] = $newarray['b_r_dark'];
$b_r_earth[$count] = $newarray['b_r_earth'];
$b_r_fire[$count] = $newarray['b_r_fire'];
$b_r_light[$count] = $newarray['b_r_light'];
$b_r_water[$count] = $newarray['b_r_water'];
$b_p_air[$count] = $newarray['b_p_air'];
$b_p_dark[$count] = $newarray['b_p_dark'];
$b_p_earth[$count] = $newarray['b_p_earth'];
$b_p_fire[$count] = $newarray['b_p_fire'];
$b_p_light[$count] = $newarray['b_p_light'];
$b_p_water[$count] = $newarray['b_p_water'];

$name[$count] = $newArray['Name'];
$equippos[$count] = $newArray['EquipPosition'];
$reqstr[$count] = $newArray['req_Strength'];
$reqend[$count] = $newArray['req_Endurance'];
$reqagi[$count] = $newArray['req_Agility'];
$reqwis[$count] = $newArray['req_Wisdom'];
$reqint[$count] = $newArray['req_Intelligence'];
$reqatt[$count] = $newArray['req_Attack'];
$b_str[$count] = $newArray['b_str'];
$b_end[$count] = $newArray['b_end'];
$b_agi[$count] = $newArray['b_agi'];
$b_wis[$count] = $newArray['b_wis'];
$b_int[$count] = $newArray['b_int'];
$b_luck[$count] = $newArray['b_luck'];

$count++;
}
$items = $count;

$count--;
print "$count items";

echo "<table width='100%' border='1' cellspacing='0' cellpadding='0'>";
echo "<tr> 
    <th scope='col' align='center'><a href=\"t4citems.php?sort=name\">Name</a></th> 
    <th scope='col' align='center'><a href=\"t4citems.php?sort=EquipPosition\">Equip Position</a></th>
    <th scope='col' align='center'><a href=\"t4citems.php?sort=req_Strength\">Req Strength</a></th>
    <th scope='col' align='center'><a href=\"t4citems.php?sort=req_Endurance\">Req Endurance</a></th> 
    <th scope='col' align='center'><a href=\"t4citems.php?sort=req_Agility\">Req Agility</a></th>
    <th scope='col' align='center'><a href=\"t4citems.php?sort=req_Wisdom\">Req Wisdom</a></th>
    <th scope='col' align='center'><a href=\"t4citems.php?sort=req_Intelligence\">Req Intelligence</a></th>
    <th scope='col' align='center'>Bonuses</th>
    
  </tr>";
$count = 1;
while($count < $items){
print "<tr><td><b>$name[$count]</b></td><td><b>$equippos[$count]</b></td><td><b>$reqstr[$count]</b></td><td><b>$reqend[$count]</b></td><td><b>$reqagi[$count]</b></td><td><b>$reqwis[$count]</b></td><td><b>$reqint[$count]</b></td><td><b>";
if ($b_r_air[$count] != 0){
	print "($b_r_air[$count] Air Resist) ";
}
if ($b_r_dark[$count] != 0){
	print "($b_r_dark[$count] Dark Resist) ";
}
if ($b_r_earth[$count] != 0){
	print "($b_r_earth[$count] Earth Resist) ";
}
if ($b_r_fire[$count] != 0){
	print "($b_r_fire[$count] Fire Resist) ";
}
if ($b_r_light[$count] != 0){
	print "($b_r_light[$count] Light Resist) ";
}
if ($b_r_water[$count] != 0){
	print "($b_r_water[$count] Water Resist) ";
}
if ($b_str[$count] != 0){
	print "($b_str[$count] Strength) ";
}
if ($b_end[$count] != 0){
	print "($b_end[$count] Endurance) ";
}
if ($b_agi[$count] != 0){
	print "($b_agi[$count] Agility) ";
}
if ($b_wis[$count] != 0){
	print "($b_wis[$count] Wisdom) ";
}
if ($b_int[$count] != 0){
	print "($b_int[$count] Intelligence) ";
}
if ($b_luck[$count] != 0){
	print "($b_luck[$count] Luck) ";
}
if ($b_attack[$count] != 0){
	print "($b_attack[$count] Attack) ";
}
if ($b_dodge[$count] != 0){
	print "($b_dodge[$count] Dodge)";
}
if ($b_damage[$count] != 0){
	print "($b_damage[$count] Damage) ";
}
if ($b_radiance[$count] != 0){
	print "($b_radiance[$count] Radiance) ";
}
print "</b></td></tr>";
$count++;
}
echo "</table>";
?>

</body></html> 

Link to comment
https://forums.phpfreaks.com/topic/130954-some-variables-work-some-dont/
Share on other sites

Develop php code and debug php code on a system where error_reporting is set to E_ALL and display_errors is set to ON to get php to help you with problems like this. The  mis-named/mis-cased variables would have resulted in undefined error messages that would have pointed to the problem.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.