Shadowing Posted February 28, 2012 Share Posted February 28, 2012 Hey guys im having a issue with getting a radio group check box to work. Not sure what im doing wrong this is giving me a fatal error. Wanting to make it where only one box can be checked at a time. and when the attack from button is hit it assigns the value to $defender_planet <input type="checkbox" name="defender_planet" value="58"/> <input type="checkbox" name="defender_planet" value="59" /> <input type="checkbox" name="defender_planet" value="60" /> if(isset($_POST['attack_from'])) { $defender_planet = $this->input->post('defender_planet'); $planet3 = "SELECT defender_planet FROM travel WHERE defender_planet = '" .($defender_planet')."'"; $planet2 = mysql_query($planet3) or die(mysql_error()); $planet1 = mysql_fetch_array($planet2); $_SESSION['attacking_from'] = $planet1['defender_planet']; header("Location: attack.php"); exit(); } Link to comment https://forums.phpfreaks.com/topic/257915-radio-group-check-box/ Share on other sites More sharing options...
Anon-e-mouse Posted February 28, 2012 Share Posted February 28, 2012 Morning, <?php ... $planet3 = "SELECT defender_planet FROM travel WHERE defender_planet = '" .($defender_planet')."'"; ... ?> An extra apostrophe in there which is why you are getting a fatal error. The query should be as follows.. <?php ... $planet3 = "SELECT defender_planet FROM travel WHERE defender_planet = '".$defender_planet."'"; ... ?> Hope it helps.. Link to comment https://forums.phpfreaks.com/topic/257915-radio-group-check-box/#findComment-1321970 Share on other sites More sharing options...
Shadowing Posted February 28, 2012 Author Share Posted February 28, 2012 thanks Anon, acctually that was just a typo when i changed something before submiting to make it easier to read. my fatal error is coming from $army_id = $this->input->post['defender_planet']; Also missing a " would give a syntax error not a fatal error Link to comment https://forums.phpfreaks.com/topic/257915-radio-group-check-box/#findComment-1321972 Share on other sites More sharing options...
Shadowing Posted February 28, 2012 Author Share Posted February 28, 2012 I figured out my issue, also I just realized what selecting input as radio does lol. Which is actually more of what I wanted. Link to comment https://forums.phpfreaks.com/topic/257915-radio-group-check-box/#findComment-1321978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.