das ist zwar schon ein wenig älter, aber ich greife das Thema noch einmal auf.
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'),
...
meine staat.php
Code:
<?php
if (!empty($_GET['country'])) {
$link = mysql_connect('localhost', 'staat', '3mu7Wz');
if (!$link) {
die('Verbindung nicht moeglich : ' . mysql_error());
}
$db_selected = mysql_select_db('staat', $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);
}
?>
Html Ausgabe
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>
Wenn ich nun Deutschland auswähle bekomme ich die Meldung
Zitat:
|
Abfrage konnte nicht ausgefuehrt werden: Unknown column 'Deutschland' in 'where clause'
|
Ich komme einfach nicht weiter...
Kann mir bitte jemand helfen ?
Gruß
Realpommes