Fehllermeldung: "Incorrect string value: '\xDF'"

BELL

Mitglied
Hallo,

Ich habe ja jetzt einen guten script (aus dem Thema, dass ich grade für gelöst erklärt habe), aber sobald man in ein Formularfeld ein "ß" eingibt (was manchmal nötig ist), wird überhaupt nichts in die DB geschriben (sonst schon) und es wird folgende Fehlermeldung ausgespuvkt:
Code:
Incorrect string value: '\xDF' for column 'VORNAME' at row 1

Code für das Formular:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 700px;
height: 720px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 450px;">
<br>
<form action="thxb.php" method="post">
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 450px;"><font face="Arial" size="6">Ihr Vorname:  <input type="text" name="vorname" placeholder="Max" autofocus style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
<br>
<br>
<font face="Arial" size="6">Ihr Name: <input type="text" name="name" placeholder="Mustermann" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
<br>
<br>
<font face="Arial" size="6">Ihre Strasse: <input type="text" name="straße" placeholder="Musterstrasse" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
<br>
<br>
<font face="Arial" size="6">Ihre Hausnummer: <input type="number" name="hausnummer" min="1" steps="1" placeholder="42" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
<br>
<br>
<br>
<br>
<br>
<input type="image" src="Absenden.png" alt="Absenden"></div>
</form>
</div>
</div>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Zurück zur Hauptseite">
</a>
</div>
</div>
<br>
</body>
</html>

thxb.php:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL - Brötchen Einfach Liefern Lassen!</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">

<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 600px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 500px;
height: 650px;">
<font face="Agency FB" size="7">Ihre eingaben: <?php echo $_POST ?></font>

</div>
</div>
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Logo">
</a>
</div>
</div>
<br>
<br>
<?php
$db = mysqli_connect("localhost", "php", "passwort", "bell");
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
$query = "
INSERT INTO
feed
(
VORNAME,
NACHNAME,
EMAIL,
NACHRICHT
)
VALUES
(
'" . mysqli_real_escape_string($db, $_POST['vorname'])  . "',
'" . mysqli_real_escape_string($db, $_POST['name'])  . "',
'" . mysqli_real_escape_string($db, $_POST['email'])  . "',
'" . mysqli_real_escape_string($db, $_POST['nachricht']) . "'
)
";
mysqli_query($db, $query)  or die(mysqli_error($db));
?>
</body>
</html>

Ich vermute, das mit der Codierung etwas schiefläuft. Die Query, die ich mir schon durch var_dump() habe ausgeben lassen, macht in der Kommandozeile alles gut, dann wird auch das ? in die Tabelle geschrieben und alles ist super. Ich glaube daher, dass der Fehler bei der Codierung der Query abläuft, wenn die an die DB weitergegeben wird.

Danke, BELL
 
Hi

richtig, die Charsets sind Schuld.

Am wenigsten praktische Probleme hat man üblicherweise mit UTF8, und zwar:
a) Bei den betroffenen DB-Tabellenspalten (bei Verwendung von PHPmyAdmin etc. einfach über die GUI einstellbar, idealerweise auf utf8mb4. Dazu auch eine passende Collation)
b) Bei der Mysqli-Verbindung (hint: $mysqli->set_charset("utf8mb4"))
c) Im HTML-Meta-Teil (wo bei dir das falsche iso-8859-1 drinsteht)
d) Bei der HTTP-Verbindung (PHP-Anweisung "header" mit passenden Parametern :google:)
 
Hi

als ich die Änderungen gemacht hatte, war der Bildschirf von thxb.php weiss und es wurden überhaupt keine daten mehr gesendet. Könntest du es mir vielecht etwas genauer erklären :oops:

Danke, Bell
 
Guten Abend,

Ich habe es jetzt geschafft, dass mein Feedback-Formular funzt.

Fast genau den gleichen code habe ich nun für das andere Formular benutzt, dort aber gibt es immer die Fehlermeldung:

Code:
Incorrect string value: '\xDFe' for column 'strasse' at row 1

Hier die Codes:

Feedback-Formular:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL - Brötchen Einfach Liefern Lassen!</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 700px;
height: 900px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 450px;">
<br>
<form action="thxf.php" method="post">
 <div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 450px;"><font face="Arial" size="6">Ihr Vorname:  <input type="text" name="vorname" placeholder="Max" autofocus style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;"/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihr Name: <input type="text" name="name" placeholder="Mustermann" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;"/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihre E-Mail-Adresse: <input type="text" name="email" placeholder="Max@Mustermann.de" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;"/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihre Nachricht: <textarea name="nachricht" placeholder="Hi, Hier ist alles Super!" style="width: 600px; height: 360px; font-size: 30px; font-family: Arial;"></textarea></font>
 <br>
 <br>
 <br>
 <input type="image" src="Absendenf.png" alt="Absenden"></div>
</form>
</div>
</div>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 700px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Zurück zur Hauptseite">
</a>
</div>
</div>
<br>

</body>
</html>

Feedback-PHP:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL - Brötchen Einfach Liefern Lassen!</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">

<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 600px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 500px;
height: 650px;">
<font face="Agency FB" size="7">Vielen Dank für Ihre Rückmeldung! <br> Falls Sie irgend Etwas gestört haben sollte, entschuldige ich mich. Falls Ihr Erlebnis Positiv war, freue ich mich sehr! In jedem Fall werden Sie bald eine Rückmeldung per E-Mail erhalten.</font>

</div>
</div>
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Logo">
</a>
</div>
</div>
<br>
<br>
<?php
$db = mysqli_connect("localhost", "php", "passwort", "bell");
if(!$db)
{
 exit("Verbindungsfehler: ".mysqli_connect_error());
}
$query = "
INSERT INTO
feed
(
vorname,
nachname,
email,
nachricht
)
VALUES
(
'" . mysqli_real_escape_string($db, $_POST['vorname'])  . "',
'" . mysqli_real_escape_string($db, $_POST['name'])  . "',
'" . mysqli_real_escape_string($db, $_POST['email'])  . "',
'" . mysqli_real_escape_string($db, $_POST['nachricht']) . "'
)
";
mysqli_query($db, $query)  or die(mysqli_error($db));
?>
</body>
</html>

----

Code für das andere Formular:

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL - Brötchen Einfach Liefern Lassen!</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 700px;
height: 720px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 450px;">
<br>
<form action="thxb.php" method="post">
 <div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 450px;"><font face="Arial" size="6">Ihr Vorname:  <input type="text" name="vorname" placeholder="Max" autofocus style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihr Name: <input type="text" name="name" placeholder="Mustermann" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihre Strasse: <input type="text" name="strasse" placeholder="Musterstrasse" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
 <br>
 <br>
 <font face="Arial" size="6">Ihre Hausnummer: <input type="number" name="hausnummer" min="1" steps="1" placeholder="42" style="width: 100px; height: 36px; font-size: 30px; font-family: Arial;" required/></font>
 <br>
 <font face="Arial" size="6">Buchstabe Ihrer Hausnummer (wenn vorhanden): <input type="text" name="buchstabe" placeholder="a" style="width: 29px; height: 36px; font-size: 30px; font-family: Arial;" /></font>
 <br>
 <br>
 <font face="Arial" size="6" >Ihre Bäckerei:  <label>
  <select name="Bäckerei" size="1" style="width: 300px; height: 36px; font-size: 30px; font-family: Arial;">
  <option >Norberts Backwerke</option>
  <option >Scheeßel-Brötchen</option>
  <option >Dorfbäckerei</option>
  <option >Bäckerei Steinofen</option>
  <option >Aldi-Bäckrei</option>
  <option >Schulbäckerei</option>
  <option >Opa Hartmuts</option>
  <option >Bäckerei Müller</option>
  <option >Superbrote</option>
  </select>
  </label></font>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <input type="image" src="Absenden.png" alt="Absenden"></div>
</form>
</div>
</div>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Zurück zur Hauptseite">
</a>
</div>
</div>
<br>
</body>
</html>

Code für den Dazugehörigen PHP-Kram:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BELL - Brötchen Einfach Liefern Lassen!</title>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1650px;
height: 450px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 1600px;
height: 400px;
background-color: #77D4FF;">
<img style="margin: auto; width: 1600px;" src="Logo.png" alt="Logo">
</div>
</div>
</head>
<body bgcolor="#77D4FF">

<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 600px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 500px;
height: 650px;">
<font face="Agency FB" size="7">Array: <br> <br> <?php print_r($_POST); ?></font>

</div>
</div>
<br>
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 650px;
height: 130px;
background-color: #FFFFFF;">
<br>
<div style="margin-left:auto;
margin-right:auto;
width: 600px;
height: 100px;
background-color: #FFFFFF;">
<a href="/iisstart.htm">
<img style="margin: auto; width: 600px;" src="Back.png" alt="Logo">
</a>
</div>
</div>
<br>
<br>
<?php
$db = mysqli_connect("localhost", "php", "passwort", "bell");
if(!$db)
{
 exit("Verbindungsfehler: ".mysqli_connect_error());
}
$query = "
INSERT INTO
daten
(
vorname,
nachname,
strasse,
hausnummer,
buchstabe
)
VALUES
(
'" . mysqli_real_escape_string($db, $_POST['vorname'])  . "',
'" . mysqli_real_escape_string($db, $_POST['name'])  . "',
'" . mysqli_real_escape_string($db, $_POST['strasse'])  . "',
'" . mysqli_real_escape_string($db, $_POST['hausnummer']) . "',
'" . mysqli_real_escape_string($db, $_POST['buchstabe']) . "'
)
";
mysqli_query($db, $query)  or die(mysqli_error($db));
?>
</body>
</html>

Zwischen den beiden phps bestehen kaum Unterschiede, dennoch funktioniert nur das Feedback-PHP. Die Tabellen sind da, wo sie sein sollten, alle Felder dort sind vom Typ "text".
Ich kann es mir echt nicht erklären, warum das nicht funktioniert.:(

VIlen Dank fürs lesen,

Bell.
 
Also, ich weiß jetzt nicht genau, was du geändert hast; aber laut Browsersuche ist es keins der 4 genannten Sachen :rolleyes: (und alle 4 sind nötig).

(Zur DB: "Text" ist zu wenig.)
 
Hi,

Hi

als ich die Änderungen gemacht hatte, war der Bildschirm von thxb.php weiss und es wurden überhaupt keine daten mehr gesendet. Könntest du es mir vieleicht etwas genauer erklären :oops:

Danke, Bell

Egal, seitdem ich die Datentypen von (fast) allen Feldern in "longblob" geändert habe, läuft es ohne errors und generell super.

Danke für die (wiedermal) kompetente & supernette Hilfe!

Bell
 
Zurück