plik:
<?php
include("lib.php");
define("PAGENAME", "Twoje konto"); $player = check_user($secret_key, $db);
$query = $db->execute("INSERT INTO `players` SET `country`=? where `id`=?", array(sha1
($country['id']), $player
?>
<form method="POST" action="country.php">
<tr><td width="40%"><B>Wybierz swoją narodowość:</B>
<select name="country">
<? $query = $db->execute("select `id`, `country` from `country`");
while($country = $query->fetchrow()){?>
<option value="<?=$country['id']?>"><?=$country['country']?></option>
<?
}
?>
</select><br /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="register" value="Zmień!"></td></tr>
</table>
</form>
komunikat:
Kod
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where `id`='9'' at line 1
players:
-- Struktura tabeli dla `players`
--
CREATE TABLE IF NOT EXISTS `players` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`rank` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Użytkownik',
`registered` int(11) NOT NULL,
`last_active` int(11) NOT NULL,
`ip` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`level` int(11) NOT NULL DEFAULT '1',
`stat_points` int(11) NOT NULL DEFAULT '5',
`gold` int(11) NOT NULL DEFAULT '10',
`bank` int(11) NOT NULL DEFAULT '0',
`hp` int(11) NOT NULL DEFAULT '50',
`maxhp` int(11) NOT NULL DEFAULT '50',
`exp` int(11) NOT NULL DEFAULT '0',
`maxexp` int(11) NOT NULL DEFAULT '50',
`energy` int(11) NOT NULL DEFAULT '10',
`maxenergy` int(11) NOT NULL DEFAULT '10',
`strength` int(11) NOT NULL DEFAULT '1',
`vitality` int(11) NOT NULL DEFAULT '1',
`agility` int(11) NOT NULL DEFAULT '1',
`interest` tinyint(1) NOT NULL DEFAULT '0',
`kills` int(11) NOT NULL DEFAULT '0',
`deaths` int(11) NOT NULL DEFAULT '0',
`race` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`validated` int(11) NOT NULL DEFAULT '0',
`validkey` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`guild_id` int(11) DEFAULT NULL,
`country` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=30 ;
country:
-- Struktura tabeli dla `country`
--
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`country` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
W formie z 1 postu był dodawany bezwładny ciąg znaków, choć powinna być dodawana 1, więc jako tako działa, ale nie wiem co jest źle.
Problem rozwiązany przyczyną była funkcja sha1, zawdzięczam swoje problemy swojemu lenistwu, gdyż wyciołem skrawek kodu z innego mojego pliku, a to, że w php nie jestem za mocny przyczyniło się do nie odnalezienia problemu w czasie. Tu jest dobry plik.
<?php
include("lib.php");
define("PAGENAME", "Wybór narodowości"); $player = check_user($secret_key, $db);
$query = $db->execute("update `players` set `country`=? where `id`=?", array($_POST['country'], $player->id)) or
die(mysql_error()); ?>
<form method="POST" action="country.php">
<tr><td width="40%"><B>Wybierz swoją narodowość:</B>
<select name="country">
<? $query = $db->execute("select `id`, `country` from `country`");
while($country = $query->fetchrow()){?>
<option value="<?=$country['id']?>"><?=$country['country']?></option>
<?
}
?>
</select><br /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="register" value="Zmień!"></td></tr>
</table>
</form>