Początkujący
Postów: 111
Data rejestracji: 13.04.2006 11:18
|
Oryginalny skrypt:
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright (c) 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../../maincore.php";
require_once BASEDIR."subheader.php";
require_once ADMIN."navigation.php";
if (file_exists(INFUSIONS."ip_poll_panel/locale/".$settings['locale'].".php")) {
include INFUSIONS."ip_poll_panel/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."ip_poll_panel/locale/English.php";
}
if (!checkRights("IP")) fallback("../index.php");
if (isset($_POST['save'])) {
$poll_title = stripinput($poll_title);
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
if (isset($poll_id)) {
if (!isNum($poll_id)) { header("Location: ".FUSION_SELF); exit; }
$ended = (isset($_POST['close']) ? time() : 0);
$result = dbquery("UPDATE ".$db_prefix."ip_polls SET poll_title='$poll_title', poll_opt_0='$poll_option[0]', poll_opt_1='$poll_option[1]', poll_opt_2='$poll_option[2]', poll_opt_3='$poll_option[3]', poll_opt_4='$poll_option[4]', poll_opt_5='$poll_option[5]', poll_opt_6='$poll_option[6]', poll_opt_7='$poll_option[7]', poll_opt_8='$poll_option[8]', poll_opt_9='$poll_option[9]', poll_ended='$ended' WHERE poll_id='$poll_id'");
opentable($locale['PLAN_400']);
echo "<center><br>\n".$locale['PLAN_401']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
} else {
$result = dbquery("UPDATE ".$db_prefix."ip_polls SET poll_ended='".time()."' WHERE poll_ended='0'");
$result = dbquery("INSERT INTO ".$db_prefix."ip_polls VALUES('', '$poll_title', '$poll_option[0]', '$poll_option[1]', '$poll_option[2]', '$poll_option[3]', '$poll_option[4]', '$poll_option[5]', '$poll_option[6]', '$poll_option[7]', '$poll_option[8]', '$poll_option[9]', '', '', '', '', '', '', '', '', '', '', '', '".time()."', '0')");
opentable($locale['PLAN_400']);
echo "<center><br>\n".$locale['PLAN_402']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
}
} else if (isset($_POST['delete'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."ip_polls WHERE poll_id='$poll_id'");
if (dbrows($result) != 0) $result = dbquery("DELETE FROM ".$db_prefix."ip_polls WHERE poll_id='$poll_id'");
opentable($locale['PLAN_403']);
echo "<center><br>\n".$locale['PLAN_404']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
} else {
if (isset($_POST['preview'])) {
$poll = ""; $i = 0;
$poll_title = stripinput($poll_title);
while ($i < count($_POST['poll_option'])) {
$poll_option[$i] = stripinput($_POST['poll_option'][$i]);
$poll .= "<input type='checkbox' name='option[$i]'> $poll_option[$i]<br><br>\n";
$i++;
}
$opt_count = (isset($_POST['opt_count']) && $_POST['opt_count'] != 10 ? count($poll_option) : $_POST['opt_count']);
opentable($locale['PLAN_410']);
echo "<table align='center' width='280' cellpadding='0' cellspacing='0' class='tbl'>
<tr>
<td>$poll_title<br><br>
$poll</td>
</tr>
<tr>
<td align='center'><input type='button' name='blank' value='".$locale['PLAN_411']."' class='button' style='width:70px'></td>
</tr>
</table>\n";
closetable();
tablebreak();
}
$editlist = "";
$result = dbquery("SELECT * FROM ".$db_prefix."ip_polls ORDER BY poll_id DESC");
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
$editlist .= "<option value='".$data['poll_id']."'>".$data['poll_title']."</option>\n";
}
opentable($locale['PLAN_420']);
echo "<form name='editform' method='post' action='".FUSION_SELF."'>
<center>
<select name='poll_id' class='textbox' style='width:200px;'>
$editlist</select>
<input type='submit' name='edit' value='".$locale['PLAN_421']."' class='button'>
<input type='submit' name='delete' value='".$locale['PLAN_422']."' class='button'>
</center>
</form>\n";
closetable();
tablebreak();
}
if (isset($_POST['edit'])) {
if (!isNum($poll_id)) { header("Location: ".FUSION_SELF); exit; }
$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."ip_polls WHERE poll_id='$poll_id'"));
$poll_title = $data['poll_title'];
for ($i=0; $i<=9; $i++) {
if ($data["poll_opt_".$i]) $poll_option[$i] = $data["poll_opt_".$i];
}
$opt_count = count($poll_option);
$poll_started = $data['poll_started'];
$poll_ended = $data['poll_ended'];
}
if (isset($_POST['addoption'])) {
$poll_title = stripinput($_POST['poll_title']);
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
$opt_count = ($_POST['opt_count'] != 10 ? count($poll_option) + 1 : $_POST['opt_count']);
}
$i = 0; $opt = 1;
$poll_title = isset($poll_title) ? $poll_title : "";
$opt_count = isset($opt_count) ? $opt_count : 2;
if (isset($poll_id)) $poll_ended = isset($poll_ended) ? $poll_ended : 0;
opentable((isset($poll_id) ? $locale['PLAN_431'] : $locale['PLAN_430']));
echo "<form name='pollform' method='post' action='".FUSION_SELF.(isset($poll_id) ? "?poll_id=$poll_id&poll_ended=$poll_ended" : "")."'>
<table align='center' width='280' cellpadding='0' cellspacing='0' class='tbl'>
<tr>
<td width='80'>".$locale['PLAN_433']."</td><td><input type='text' name='poll_title' value='$poll_title' class='textbox' style='width:200px'></td>
</tr>
<tr>\n";
while ($i != $opt_count) {
$poll_opt = isset($poll_option[$i]) ? $poll_option[$i] : "";
echo "<tr>\n<td width='80'>".$locale['PLAN_434']."$opt</td>\n";
echo "<td><input type='text' name='poll_option[$i]' value='$poll_opt' class='textbox' style='width:200px'></td>\n</tr>\n";
$i++; $opt++;
}
echo "</table>
<table align='center' width='280' cellpadding='0' cellspacing='0'>
<tr>
<td align='center'><br>\n";
if (isset($poll_id) && $poll_ended == 0) {
echo "<input type='checkbox' name='close' value='yes'>".$locale['PLAN_435']."<br><br>\n";
}
if (!isset($poll_id) || isset($poll_id) && $poll_ended == 0) {
echo "<input type='hidden' name='opt_count' value='$opt_count'>
<input type='submit' name='addoption' value='".$locale['PLAN_438']."' class='button'>
<input type='submit' name='preview' value='".$locale['PLAN_439']."' class='button'>
<input type='submit' name='save' value='".$locale['PLAN_440']."' class='button'>\n";
} else {
echo $locale['PLAN_436'].showdate("shortdate", $poll_started)."<br>\n";
echo $locale['PLAN_437'].showdate("shortdate", $poll_ended)."<br>\n";
}
echo "</td>\n</tr>\n</table>\n</form>\n";
closetable();
}
echo "</td>\n";
require_once BASEDIR."footer.php";
?>
Przerobioy skrypt:
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright (c) 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../../maincore.php";
require_once BASEDIR."subheader.php";
require_once ADMIN."navigation.php";
if (file_exists(INFUSIONS."ip_poll_panel1/locale/".$settings['locale'].".php")) {
include INFUSIONS."ip_poll_panel1/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."ip_poll_panel1/locale/English.php";
}
if (!checkRights("IP")) fallback("../index.php");
if (isset($_POST['save'])) {
$poll_title = stripinput($poll_title);
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
if (isset($poll_id)) {
if (!isNum($poll_id)) { header("Location: ".FUSION_SELF); exit; }
$ended = (isset($_POST['close']) ? time() : 0);
$result = dbquery("UPDATE ".$db_prefix."ip_polls1 SET poll_title='$poll_title', poll_opt_0='$poll_option[0]', poll_opt_1='$poll_option[1]', poll_opt_2='$poll_option[2]', poll_opt_3='$poll_option[3]', poll_opt_4='$poll_option[4]', poll_opt_5='$poll_option[5]', poll_opt_6='$poll_option[6]', poll_opt_7='$poll_option[7]', poll_opt_8='$poll_option[8]', poll_opt_9='$poll_option[9]', poll_opt_10='$poll_option[10]', poll_opt_11='$poll_option[11]', poll_opt_12='$poll_option[12]', poll_opt_13='$poll_option[13]', poll_opt_14='$poll_option[14]', poll_opt_15='$poll_option[15]', poll_opt_16='$poll_option[16]', poll_opt_17='$poll_option[17]', poll_opt_18='$poll_option[18]', poll_opt_19='$poll_option[19]', poll_opt_20='$poll_option[21]', poll_opt_22='$poll_option[22]', poll_opt_23='$poll_option[23]', poll_opt_24='$poll_option[24]', poll_opt_25='$poll_option[25]', poll_opt_26='$poll_option[26]', poll_opt_27='$poll_option[27]', poll_opt_28='$poll_option[28]', poll_opt_29='$poll_option[29]', poll_ended='$ended' WHERE poll_id='$poll_id'");
opentable($locale['PLAN_400']);
echo "<center><br>\n".$locale['PLAN_401']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
} else {
$result = dbquery("UPDATE ".$db_prefix."ip_polls1 SET poll_ended='".time()."' WHERE poll_ended='0'");
$result = dbquery("INSERT INTO ".$db_prefix."ip_polls1 VALUES('', '$poll_title', '$poll_option[0]', '$poll_option[1]', '$poll_option[2]', '$poll_option[3]', '$poll_option[4]', '$poll_option[5]', '$poll_option[6]', '$poll_option[7]', '$poll_option[8]', '$poll_option[9]', '$poll_option[10]', '$poll_option[11]', '$poll_option[12]', '$poll_option[13]', '$poll_option[14]', '$poll_option[15]', '$poll_option[16]', '$poll_option[17]', '$poll_option[18]', '$poll_option[19]', '$poll_option[20]', '$poll_option[21]', '$poll_option[22]', '$poll_option[23]', '$poll_option[24]', '$poll_option[25]', '$poll_option[26]', '$poll_option[27]', '$poll_option[28]', '$poll_option[29]', '', '', '', '', '', '', '', '', '', '', '', '".time()."', '0')");
opentable($locale['PLAN_400']);
echo "<center><br>\n".$locale['PLAN_402']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
}
} else if (isset($_POST['delete'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."ip_polls1 WHERE poll_id='$poll_id'");
if (dbrows($result) != 0) $result = dbquery("DELETE FROM ".$db_prefix."ip_polls1 WHERE poll_id='$poll_id'");
opentable($locale['PLAN_403']);
echo "<center><br>\n".$locale['PLAN_404']."<br><br>\n<a href='".ADMIN."index.php'>".$locale['PLAN_405']."</a><br><br>\n</center>\n";
closetable();
} else {
if (isset($_POST['preview'])) {
$poll = ""; $i = 0;
$poll_title = stripinput($poll_title);
while ($i < count($_POST['poll_option'])) {
$poll_option[$i] = stripinput($_POST['poll_option'][$i]);
$poll .= "<input type='checkbox' name='option[$i]'> $poll_option[$i]<br><br>\n";
$i++;
}
$opt_count = (isset($_POST['opt_count']) && $_POST['opt_count'] != 30 ? count($poll_option) : $_POST['opt_count']);
opentable($locale['PLAN_410']);
echo "<table align='center' width='280' cellpadding='0' cellspacing='0' class='tbl'>
<tr>
<td>$poll_title<br><br>
$poll</td>
</tr>
<tr>
<td align='center'><input type='button' name='blank' value='".$locale['PLAN_411']."' class='button' style='width:70px'></td>
</tr>
</table>\n";
closetable();
tablebreak();
}
$editlist = "";
$result = dbquery("SELECT * FROM ".$db_prefix."ip_polls1 ORDER BY poll_id DESC");
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
$editlist .= "<option value='".$data['poll_id']."'>".$data['poll_title']."</option>\n";
}
opentable($locale['PLAN_420']);
echo "<form name='editform' method='post' action='".FUSION_SELF."'>
<center>
<select name='poll_id' class='textbox' style='width:200px;'>
$editlist</select>
<input type='submit' name='edit' value='".$locale['PLAN_421']."' class='button'>
<input type='submit' name='delete' value='".$locale['PLAN_422']."' class='button'>
</center>
</form>\n";
closetable();
tablebreak();
}
if (isset($_POST['edit'])) {
if (!isNum($poll_id)) { header("Location: ".FUSION_SELF); exit; }
$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."ip_polls1 WHERE poll_id='$poll_id'"));
$poll_title = $data['poll_title'];
for ($i=0; $i<=29; $i++) {
if ($data["poll_opt_".$i]) $poll_option[$i] = $data["poll_opt_".$i];
}
$opt_count = count($poll_option);
$poll_started = $data['poll_started'];
$poll_ended = $data['poll_ended'];
}
if (isset($_POST['addoption'])) {
$poll_title = stripinput($_POST['poll_title']);
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
$opt_count = ($_POST['opt_count'] != 30 ? count($poll_option) + 1 : $_POST['opt_count']);
}
$i = 0; $opt = 1;
$poll_title = isset($poll_title) ? $poll_title : "";
$opt_count = isset($opt_count) ? $opt_count : 2;
if (isset($poll_id)) $poll_ended = isset($poll_ended) ? $poll_ended : 0;
opentable((isset($poll_id) ? $locale['PLAN_431'] : $locale['PLAN_430']));
echo "<form name='pollform' method='post' action='".FUSION_SELF.(isset($poll_id) ? "?poll_id=$poll_id&poll_ended=$poll_ended" : "")."'>
<table align='center' width='280' cellpadding='0' cellspacing='0' class='tbl'>
<tr>
<td width='80'>".$locale['PLAN_433']."</td><td><input type='text' name='poll_title' value='$poll_title' class='textbox' style='width:200px'></td>
</tr>
<tr>\n";
while ($i != $opt_count) {
$poll_opt = isset($poll_option[$i]) ? $poll_option[$i] : "";
echo "<tr>\n<td width='80'>".$locale['PLAN_434']."$opt</td>\n";
echo "<td><input type='text' name='poll_option[$i]' value='$poll_opt' class='textbox' style='width:200px'></td>\n</tr>\n";
$i++; $opt++;
}
echo "</table>
<table align='center' width='280' cellpadding='0' cellspacing='0'>
<tr>
<td align='center'><br>\n";
if (isset($poll_id) && $poll_ended == 0) {
echo "<input type='checkbox' name='close' value='yes'>".$locale['PLAN_435']."<br><br>\n";
}
if (!isset($poll_id) || isset($poll_id) && $poll_ended == 0) {
echo "<input type='hidden' name='opt_count' value='$opt_count'>
<input type='submit' name='addoption' value='".$locale['PLAN_438']."' class='button'>
<input type='submit' name='preview' value='".$locale['PLAN_439']."' class='button'>
<input type='submit' name='save' value='".$locale['PLAN_440']."' class='button'>\n";
} else {
echo $locale['PLAN_436'].showdate("shortdate", $poll_started)."<br>\n";
echo $locale['PLAN_437'].showdate("shortdate", $poll_ended)."<br>\n";
}
echo "</td>\n</tr>\n</table>\n</form>\n";
closetable();
}
echo "</td>\n";
require_once BASEDIR."footer.php";
?>
Probuje przerobic skyt tak aby bylo 30 mozliwych pol wszystk osie ladnie dodaje do bazy juz i gdy probije zorbic ankiete to wystepuje blad
Column count doesn't match value count at row 1
Nie mam pojecia dlaczego moze cos jeszcze powinienem zmodyfikowac ?? Tylko co zaznaczam ze moja wiedza na temat baz danych jest mierna.
Odrazu zaznaczam ze szukalem rozwiazania na forum i znalzlame jedno z podpisem ze trzeba cos zrobic w bazie zglaszac sie na gg ale jak pisze do tej osoby to ona nie odpisuje wiec prosze o pomoc.
|