Jump to content

radio group check box


Shadowing

Recommended Posts

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

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..

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

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.