Habe danach gesucht, doch leider funktioniert es dennoch nicht.
Ich habe eine Datenbank mit dem Namen staat angelegt.
Hier drinne ist eine Tabelle mit dem Namen country.
meine staat.php
Html Ausgabe
Wenn ich nun Deutschland auswähle bekomme ich die Meldung
Ich komme einfach nicht weiter...
Kann mir bitte jemand helfen ?
Gruß
Realpommes
Ich habe eine Datenbank mit dem Namen staat angelegt.
Hier drinne ist eine Tabelle mit dem Namen country.
Code:
CREATE TABLE `country` ( `id` int(11) NOT NULL auto_increment, `country` varchar(64) collate latin1_german2_ci NOT NULL default '-', `country_iso` char(5) collate latin1_german2_ci NOT NULL default '-', `country_code` varchar(12) collate latin1_german2_ci NOT NULL default '-', PRIMARY KEY (`id`), KEY `country` (`country`), KEY `country_iso` (`country_iso`), KEY `country_code` (`country_code`) ); INSERT INTO `country` (`id`, `country`, `country_iso`, `country_code`) VALUES (1, 'Deutschland', 'DE', '0049'), (2, 'Österreich', 'A', '0043'), ...
Code:
<?php
if (!empty($_GET['country'])) {
$link = mysql_connect('localhost', 'country', '3mu7wZ');
if (!$link) {
die('Verbindung nicht moeglich : ' . mysql_error());
}
$db_selected = mysql_select_db('country', $link);
if (!$db_selected) {
die ('Kann Tabelle nicht benutzen : ' . mysql_error());
}
$result = mysql_query("SELECT country_code FROM country WHERE country_iso = ".$_GET['country']);
if (!$result) {
echo 'Abfrage konnte nicht ausgefuehrt werden: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0];
mysql_close($link);
}
?>
Code:
<tr>
<td> <label>Land:</label><select name="Staat" id="country">
<option value="Deutschland" selected="selected">Deutschland</option>
<option value="Österreich">Österreich</option>
....
</select>
<br /></td></tr>
<tr>
<td><label>Landesvorwahl:</label>
<input type="text" name="Landesvorwahl" id="country_code" value="" size="50"/></td>
</tr>
Abfrage konnte nicht ausgefuehrt werden: Unknown column 'Deutschland' in 'where clause'
Kann mir bitte jemand helfen ?
Gruß
Realpommes

Kommentar