kaitokid41 Posted January 16, 2011 Share Posted January 16, 2011 I have this main program calculating the hamming code of an 8-bit value (assuming all inputs are 1's and 0's) but i'm stuck in outputting its check bits... <head> <title>Hamming Code Calculator</title> </head> <body bgcolor="white"> <form action="getvalues.php" method="get"> <table width="800" border="1" STYLE="background-color:#CF3"> <tr> <td><input type="text" name="d8" size=1></td> <td><input type="text" name="d7" size=1></td> <td><input type="text" name="d6" size=1></td> <td><input type="text" name="d5" size=1></td> <td><input type="text" name="d4" size=1></td> <td><input type="text" name="d3" size=1></td> <td><input type="text" name="d2" size=1></td> <td><input type="text" name="d1" size=1></td> </tr> </table> <input type="submit" value="Calculate"> </form> </body> </html> and the file to be accessed is this... </head> <body> <?php $d1=$_GET["d1"]; $d2=$_GET["d2"]; $d3=$_GET["d3"]; $d4=$_GET["d4"]; $d5=$_GET["d5"]; $d6=$_GET["d6"]; $d7=$_GET["d7"]; $d8=$_GET["d8"]; $c1 = $d1 ^ $d2 ^ $d4 ^ $d5 ^ $d7; $c2 = $d1 ^ $d3 ^ $d4 ^ $d6 ^ $d7; $c4 = $d2 ^ $d3 ^ $d4 ^ $d8; $c8 = $d5 ^ $d6 ^ $d7 ^ $d8; ?> <table width="400" border="2" height="100"> <tr> <td><?php echo "_"; ?></td> <td><?php echo $d7; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d5; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d4; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d2; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d1; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> </tr> <tr> <td><?php echo "_"; ?></td> <td><?php echo $d7; ?></td> <td><?php echo $d6; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d4; ?></td> <td><?php echo $d3; ?></td> <td><?php echo "_"; ?></td> <td><?php echo " "; ?></td> <td><?php echo $d1; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> </tr> <tr> <td><?php echo $d8; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo $d4; ?></td> <td><?php echo $d3; ?></td> <td><?php echo $d2; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> </tr> <tr> <td><?php echo $d8; ?></td> <td><?php echo $d7; ?></td> <td><?php echo $d6; ?></td> <td><?php echo $d5; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> <td><?php echo "_"; ?></td> </tr> </table> <?php echo $c1; echo $c2; echo $c4; echo $c8; ?> </body> </html> ...and for some reason, i can't see the output of $c4 and $c8. is there anything wrong with my code? advance thank you for those who'll help! Link to comment https://forums.phpfreaks.com/topic/224642-xor-help/ Share on other sites More sharing options...
requinix Posted January 16, 2011 Share Posted January 16, 2011 Everything in $_GET, $_POST, and $_COOKIE is a string. If you want to do an XOR and get results the way you expect them, you need to use numbers. $d1=(int)$_GET["d1"]; Link to comment https://forums.phpfreaks.com/topic/224642-xor-help/#findComment-1160392 Share on other sites More sharing options...
kaitokid41 Posted January 17, 2011 Author Share Posted January 17, 2011 wow! works like charm! hahaha! thank you very much! sorry im kinda noob when it comes to php. im still just learning the beautiful language. thanks again! Link to comment https://forums.phpfreaks.com/topic/224642-xor-help/#findComment-1160639 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.