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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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