PHP
<?php
require_once("php/verbindung.php");
$partyskill = "";
$partyskill2 = "";
$partylang = "";
$partycount = "";
$drop = "";
$error_count = "";
$error_lang = "";
$freigabe = true;
if (isset($_POST['submit'])) {
$partyskill = "$_POST[skill]";
$partyskill2 = "$_POST[skill2]";
$partylang = "$_POST[language]";
$partycount = "$_POST[count]";
if (strlen($partycount) == 0) {
$error_count = "<FONT COLOR='#d1a200'>*please select how many players you are looking for</font>";
$freigabe = false;
}
if (strlen($partylang) == 1) {
if($partylang=="1")
{$drop="gb.png";}
elseif($partylang== "2")
{$drop="de.png";}
elseif($partylang== "3")
{$drop="ru.png";}
else {
$error_lang = "<FONT COLOR='#d1a200'>*please select a language</font>";
$freigabe = false;
}
}
else {
$error_lang = "<FONT COLOR='#d1a200'>*please select a language</font>";
$freigabe = false;
}
if ($freigabe == true) {
$sql = "INSERT INTO ".$tblparty;
$sql .= " (skill, skill2, count, language)
VALUES (";
$sql .= "'".$partyskill."', ";
$sql .= "'".$partyskill2."', ";
$sql .= "'".$partycount."', ";
$sql .= "'".$drop."') ";
$query = mysql_query($sql, $verb);
}
}
&GT;
HTML
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="new_party" >
<h3>How many players are you searching for?</h3>
<p>
<input type="radio" name="count" value="1"> 1
<input type="radio" name="count" value="2"> 2
<input type="radio" name="count" value="3"> 3
<input type="radio" name="count" value="4"> 4
</p>
<?php echo $error_count; ?><br/>
<h3>What is you prefered language?</h3>
<p>
<input type="radio" name="language" value="1"><img src="images/flags/gb.png"/>
<input type="radio" name="language" value="2"><img src="images/flags/de.png"/>
<input type="radio" name="language" value="3"><img src="images/flags/ru.png"/>
</p>
<?php echo $error_lang; ?><br/>
<h3>What skill are you looking for?</h3>
from:
<select name="skill">
<option value="15">Eagle Master</option>
<option value="16">Legendary Eagle Master</option>
<option value="17">Supreme Master First Class</option>
<option value="18">Global Elite</option>
</select>
to:
<select name="skill2">
<option value="15">Eagle Master</option>
<option value="16">Legendary Eagle Master</option>
<option value="17">Supreme Master First Class</option>
<option value="18">Global Elite</option>
</select>
<input type="submit" value="Send" name="submit"/>
</form>
答案 0 :(得分:0)
而不是:
$sql = "INSERT INTO ".$tblparty;
$sql .= " (skill, skill2, count, language)
VALUES (";
$sql .= "'".$partyskill."', ";
$sql .= "'".$partyskill2."', ";
$sql .= "'".$partycount."', ";
$sql .= "'".$drop."') ";
将其更改为:
$sql = "INSERT INTO `$tblparty` (`skill`, `skill2`, `count`, `language`)
VALUES ('".$partyskill."', '".$partyskill2."', '".$partycount."', '".$drop."')";
然后删除您的skill
列并重新创建。您也可以尝试重建表格。
此外,我建议您使用mysqli_*
或prepared statements
切换到PDO个功能,mysql_*
函数已弃用,将在以后的版本中删除。