Jump to content

New problem with radio buttons


blink359

Recommended Posts

Right ive solved my last problem but when i got to make an account it now says Error: (1136) Column count doesn't match value count at row

Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:9px;
top:336px;
width:1144px;
height:40px;
z-index:1;
}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
#apDiv2 {
position:absolute;
left:13px;
top:417px;
width:934px;
height:1657px;
z-index:1;
}
#apDiv3 {
position:absolute;
left:32px;
top:32px;
width:593px;
height:101px;
z-index:2;
}
.style1 {
font-size: xx-large
}
-->
</style>
</head>

<body>
<div id="apDiv2">
<?php 
$dbhost = "localhost"; 
$dbuser = "nathan"; 
$dbpass = "your_password"; 
$dbname = "logon"; 


mysql_connect($dbhost, $dbuser, $dbpass); 
mysql_select_db($dbname); 
  
$user = $_POST['user']; 
$pass = $_POST['pass']; 
$pass2 = $_POST['pass2'];
$flag = $_POST['flag'];
  
$success = true; 
$problemMessage = ""; 
if (isset($_POST['Submit'])) 
{ 
        if(!$user || !$pass || !$pass2) 
        { 
            $problemMessage .= "Please complete all required data <br />"; 
            $success = false; 
        } 
        if(strlen($user) < 5) 
        { 
            $problemMessage .= "User must be more that 5 characters <br />"; 
            $success = false; 
        } 
        if(strlen($user) > 20) 
        { 
            $problemMessage .= "Your username cannot be longer than 20 characters <br />"; 
            $success = false; 
        } 
        if($pass != $pass2) 
        { 
            $problemMessage .= "Your passwords do not match <br />"; 
            $success = false; 
        } 
        if(strlen($pass2) < 5) 
        { 
            $problemMessage .= "Your password must be more than 5 characters<br />"; 
            $success = false; 
        } 
        if(strlen($pass2) > 20) 
        { 
            $problemMessage .= "Your password cannot be longer than 20 characters <br />"; 
            $success = false; 
        }  
         
        if ($success) 
        { 
            echo "Valid New Account Entry<br />"; 
            $result = mysql_query("INSERT INTO `accounts` VALUES ('', '$user', '$pass2', '', '', '0', '9', '', '', '$flag', 'enUS', '0', '0', null)")
             or die("Error: (" . mysql_errno() . ") " . mysql_error()); 
        } 
} 

  
?> 

<?php 
if ($success == false) { 
    echo $problemMessage; 
} 
?> 
<center><form method="post" action=""> 
    Account Creation Page<br> 
    Username: <input name="user" type="text"/><br>  
    Password: <input name="pass" type="text"/><br>  
    Repeat Password: <input name="pass2" tpye="text"/><br>  
Pre TBC<input type="radio" name="flag" value="0" /> 
TBC Enabled<input type="radio" name="flag" value="8" /> 
WOTLK Enabled<input type="radio" name="flag" value="24" />


    <input name="Submit" type="submit" value="submit" /> 
    <imput name="reset" type="reset" value="reset" /> 
</form></center>  </h1></div>
<div id="apDiv3">
  <h1 class="style1">Server Name Goes here</h1>
</div>
<p><img src="Images/Image2.jpg" width="1143" height="321" /></p>
<p><a href="index.html"><img src="Images/Home.jpg" width="150" height="50" /></a><a href="phpbb3/index.php"><img src="Images/Forums.jpg" width="150" height="50" /></a><a href="Register.php"><img src="Images/Create.jpg" width="250" height="50" /></a><a href="vote.php"><img src="Images/Vote.jpg" width="150" height="50" /></a><a href="donate.html"><img src="Images/Donate.jpg" width="150" height="50" /></a></p>
<p> </p>
</body>


</html>

Link to comment
https://forums.phpfreaks.com/topic/155608-new-problem-with-radio-buttons/
Share on other sites

Probably you have somewhere in your query a rong value with a wrong column,

to have a better view you can best do it this way:

$result = mysql_query("INSERT INTO accounts(colum1name,column2name) VALUES ('column1value','column2value')");

 

And so on... this way you can check which value goes to which column. ;D

But my mysql query is correct the only thing i changed from when it was working was

$result = mysql_query("INSERT INTO `accounts` VALUES ('', '$user', '$pass2', '', '', '0', '9', '', '', '$flag', 'enUS', '0', '0', null)")

where it says $flag it used to be 24 which is one of the possible values from my radio buttons which is:

Pre TBC<input type="radio" name="flag" value="0" />

TBC Enabled<input type="radio" name="flag" value="8" />

WOTLK Enabled<input type="radio" name="flag" value="24" />

 

That's  weird, but I currently have the same problem with one of my pages,

the radio buttons don't send a value,

 

You can check to see if they send a value,

by somewhere echo'ing the $flag,

or by print_r($flag),

if nothing is shown, you have the same probl as I have :D

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.