[PHP & MySQL] Problem mit dem Formular zum Eintragen von Werten in eine Datenbank

Marina347
Hallo,
mit diesem Tutorial habe ich ein Formular samt php-Code "gebastelt", um Werte in eine Datenbank (phpmyadmin) eintragen zu lassen.
Leider ist nun irgendwo ein Fehler, da immer "Fehler" angezeigt wird.

Hier kommen nun die Quelltexte (vorsicht - lang!)

Pferde_eintragen.php
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
<html>
  <head>
    <title>Pferde eintragen</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="style_form.css">
</head>
  <body>
    <form action="pferde_eintragen_send.php" method="POST">
    <table border=1 width="450" height="25">
    <tbody>
    <tr>
    <th>Formular für das Eintragen der Pferde</th>
    </tr>
    </tbody>
    </table>
    <br>
    <table border=0 width="400" cellspacing=5>
    <tbody>
    <tr>
    <th colspan=2>Allgemeines</th>
    </tr>
    <tr>
    <td class= "table2" width=40%>Name:</td>
    <td width=60%><input type="text" name="Name" size="30" value="ohne Titel, mit Zuchtzeichen"></td>
    </tr>
    <tr>
    <td class= "table2">Rufname:</td>
    <td><input type="text" name="Rufname" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Geburtstag:</td>
    <td><input type="text" name="Geburtstag" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Alter:</td>
    <td><input type="text" name="GebA" size="30"></td>
    </tr>
    <tr>
    <td class="table2">Geschlecht:</td>
    <td>
    <select name="Geschlecht" size="1" width="30">
    <option>Hengst</option>
    <option>Stute</option>
    <option>Wallach</option>
    </td>
    </tr>
    <tr>
    <td class= "table2">Rasse:</td>
    <td><input type="text" name="Rasse" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Farbe:</td>
    <td><input type="text" name="Farbe" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Stockmaß:</td>
    <td><input type="text" name="STM" size="10">&nbsp;&nbsp;m</td>
    </tr>
    </tr>
    <tr>
    <td class= "table2">Besitzer:</td>
    <td><input type="text" name="Besitzer" size="30" value="Deckstation Aurora"></td>
    </tr>
    <tr>
    <td class= "table2">Vorbesitzer:</td>
    <td><input type="text" name="Vorbesitzer" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Züchter:</td>
    <td><input type="text" name="Züchter" size="30"></td>
    </tr>
    <tr>
    <th colspan=2>Charakter</th>
    </tr>
    <tr>
    <td colspan=2><textarea name="Charakter" rows="10" cols="60"></textarea></TD>
    </tr>
    <tr>
    <th colspan=2>Umgang</th>
    </tr>
    <tr>
    <td class= "table2">Verladefromm:</td>
    <td><input type="text" name="Verladefromm" size="15">&nbsp;&nbsp;%</td>
    </tr>
    <tr>
    <td class= "table2">Schmiedefromm:</td>
    <td><input type="text" name="Schmiedefromm" size="15">&nbsp;&nbsp;%</td>
    </tr>
    <tr>
    <td class= "table2">Turniererfahrung:</td>
    <td><input type="text" name="Turniererfahrung" size="15">&nbsp;&nbsp;%</td>
    </tr>
    <tr>
    <td class= "table2">Geländesicher:</td>
    <td><input type="text" name="Geländesicher" size="15">&nbsp;&nbsp;%</td>
    </tr>
    <tr>
    <td class= "table2">Straßensicher:</td>
    <td><input type="text" name="Straßensicher" size="15">&nbsp;&nbsp;%</td>
    </tr>
    <tr>
    <td class= "table2">Temperament:</td>
    <td><input type="text" name="Temperament" size="15">&nbsp;&nbsp;%</td>
    </tr>
    </tbody>
    </table>
    <table border=0 width=400 cellspacing=5>
    <tbody>
    <tr>
    <th colspan=3>Ausbildung</th>
    </tr>
    <tr>
    <td class="table2" width=40%>Disziplin</td>
    <td class="table2" width=30%>Ausgebildet bis</td>
    <td class="table2" width=30%>Potential</td>
    </tr>
    <tr>
    <td class= "table2">Dressur</td>
    <td><input type="text" name="DrAus" size="8"></td>
    <td><input type="text" name="DrPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Springen</td>
    <td><input type="text" name="SprAus" size="8"></td>
    <td><input type="text" name="SprPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Vielseitigkeit</td>
    <td><input type="text" name="VSAus" size="8"></td>
    <td><input type="text" name="VSPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Western</td>
    <td><input type="text" name="WAus" size="8"></td>
    <td><input type="text" name="WPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Distanz</td>
    <td><input type="text" name="DiAus" size="8"></td>
    <td><input type="text" name="DiPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Rennen</td>
    <td><input type="text" name="ReAus" size="8"></td>
    <td><input type="text" name="RePot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Fahren</td>
    <td><input type="text" name="FaAus" size="8"></td>
    <td><input type="text" name="FaPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Voltigieren</td>
    <td><input type="text" name="VoAus" size="8"></td>
    <td><input type="text" name="VoPot" size="8"></td>
    </tr>
    <tr>
    <td class= "table2">Andere Sportarten</td>
    <td><input type="text" name="ASAus" size="8"></td>
    <td><input type="text" name="ASPot" size="8"></td>
    </tr>
    </tbody>
    </table>
    <table border=0 width="400" cellspacing=5>
    <tbody>
    <tr>
    <th colspan=2>Ausbildungsdaten</th>
    </tr>
    <tr>
    <td class= "table2" width=40%>Pfleger:</td>
    <td width=60%><input type="text" name="Pfleger" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Trainer:</td>
    <td><input type="text" name="Trainer" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Ausbilder:</td>
    <td><input type="text" name="Ausbilder" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Turnierreiter:</td>
    <td><input type="text" name="Turnierreiter" size="30"></td>
    </tr>
    <tr>
    <th colspan=2>Erfolgsübersicht</th>
    </tr>
    <tr>
    <td class= "table2" width=40%>Gesamtgewinnsumme:</td>
    <td width60%><input type="text" name="Gesamtgewinnsumme" size="15">&nbsp;&nbsp;€</td>
    </tr>
    <tr>
    <td class= "table2">Sachpreise:</td>
    <td><textarea name="Sachpreise" rows="5" cols="35">Bitte Zeilenumbrüche mit <br> schreiben.
Wenn keine Preise vorhanden sind, diesen Text löschen.</textarea></td>
    </tr>
    </tbody>
    </table>
    <table border=0 width="400" cellspacing=5>
    <tbody>
    <tr>
    <th colspan=3>Abstammung</th>
    </tr>
    <tr>
    <td rowSpan=4 width=33%><input type="text" name="V" size="17" value="Vater"></TD>
    <td rowSpan=2 width=33%><input type="text" name="VV" size="17"></TD>
    <td width=33%><input type="text" name="VVV" size="17"></TD>
    </TR>
    <TR>
    <TD><input type="text" name="VVM" size="17"></TD>
    </TR>
    <TR>
    <TD rowSpan=2><input type="text" name="VM" size="17"></TD>
    <td><input type="text" name="VMV" size="17"></TD>
    </TR>
    <TR>
    <TD><input type="text" name="VMM" size="17"></TD>
    </TR>
    <tr>
    <td colspan=3><hr size=1 width=80%></td>
    </tr>
    <TR>
    <td rowSpan=4><input type="text" name="M" size="17" value="Mutter"></TD>
    <td rowSpan=2><input type="text" name="MV" size="17"></TD>
    <td><input type="text" name="MVV" size="17"></TD>
    </TR>
    <TR>
    <TD><input type="text" name="MVM" size="17"></TD>
    </TR>
    <TR>
    <TD rowSpan=2><input type="text" name="MM" size="17"></TD>
    <td><input type="text" name="MMV" size="17"></TD>
    </TR>
    <TR>
    <TD><input type="text" name="MMM" size="17"></TD>
    </TR>
    </tbody>
    </table>
    <table border=0 width="400" cellspacing=5>
    <tbody>
    <tr>
    <th colspan=3>Zuchtinformationen</th>
    </tr>
    <tr>
    <td class="table2" width=40%>Zur Zucht zugelassen:</td>
    <td width=60%>
    <select name="Zuchtzulassung" size="1" width="30">
    <option>ja</option>
    <option>nein</option>
    </td>
    </tr>
    <tr>
    <td class= "table2">Titel:</td>
    <td><input type="text" name="Titel" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Wertnote:</td>
    <td><input type="text" name="Wertnote" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Nachweis:</td>
    <td><input type="text" name="Nachweis" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Für folgende Rassen zugelassen:</td>
    <td><input type="text" name="ZuRasse" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Nachkommen:</td>
    <td><input type="text" name="Nachkommen" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Decktaxe:</td>
    <td><input type="text" name="Decktaxe" size="15">&nbsp;&nbsp;€</td>
    </tr>
    <tr>
    <th colspan=3>Fotos</th>
    </tr>
    <tr>
    <td class= "table2">Fotograf:</td>
    <td><input type="text" name="Fotograf" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Link:</td>
    <td><input type="text" name="Fotolink" size="30"></td>
    </tr>
    <tr>
    <td class= "table2">Bilderanzahl:</td>
    <td><input type="text" name="Fotoanzahl" size="5"></td>
    </tr>
    <tr>
    <td class= "table2">Fotos:</td>
    <td><textarea name="Fotos" rows="5" cols="35">Bitte den Quelltext angeben: ab <img><textarea></td>
    </tr>
    </tbody>
    </table>
    <br><br>
    <input type="submit" value="Senden">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" value="Neu">
    </tr>
    </tbody>
    </table>
    </form>
  </body>
</html>


pferde_eintragen_send.php
php:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:

<html>
  <head>
    <title>Deckstation Aurora</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
     <link rel="stylesheet" href="/DS%20Aurora/style.css">
  </head>
  <body>
    <?php
    //Datenbankverbindung einfügen!
   include('datenbank.php');
   //Variablen festlegen
  $name $_POST['Name'];
  $rufname $_POST['Rufname'];
  $geburtstag $_POST['Geburtstag'];
  $geba $_POST['GebA'];
  $geschlecht $_POST['Geschlecht'];
  $rasse $_POST['Rasse'];
  $farbe $_POST['Farbe'];
  $stm $_POST['STM'];
  $besitzer $_POST['Besitzer'];
  $vorbesitzer $_POST['Vorbesitzer'];
  $züchter $_POST['Züchter'];
  $charakter $_POST['Charakter'];
  $verladefromm $_POST['Verladefromm'];
  $schmiedefromm $_POST['Schmiedefromm'];
  $turniererfahrung $_POST['Turniererfahrung'];
  $geländesicher $_POST['Geländesicher'];
  $straßensicher $_POST['Straßensicher'];
  $temperament $_POST['Temperament'];
  $draus $_POST['DrAus'];
  $drpot $_POST['DrPot'];
  $spraus $_POST['SprAus'];
  $sprpot $_POST['SprPot'];
  $vsaus $_POST['VSAus'];
  $vspot $_POST['VSPot'];
  $waus $_POST['WAus'];
  $wpot $_POST['WPot'];
  $diaus $_POST['DiAus'];
  $dipot $_POST['DiPot'];
  $reaus $_POST['ReAus'];
  $repot $_POST['RePot'];
  $faaus $_POST['FaAus'];
  $fapot $_POST['FaPot'];
  $voaus $_POST['VoAus'];
  $vopot $_POST['VoPot'];
  $asaus $_POST['ASAus'];
  $aspot $_POST['ASPot'];
  $pfleger $_POST['Pfleger'];
  $trainer $_POST['Trainer'];
  $ausbilder $_POST['Ausbilder'];
  $turnierreiter $_POST['Turnierreiter'];
  $gesamtgewinnsumme $_POST['Gesamtgewinnsumme'];
  $sachpreise $_POST['Sachpreise'];
  $v $_POST['V'];
  $vv $_POST['VV'];
  $vvv $_POST['VVV'];
  $vvm $_POST['VVM'];
  $vm $_POST['VM'];
  $vmv $_POST['VMV'];
  $vmm $_POST['VMM'];
  $m $_POST['M'];
  $mv $_POST['MV'];
  $mvv $_POST['MVV'];
  $mvm $_POST['MVM'];
  $mm $_POST['MM'];
  $mmv $_POST['MMV'];
  $mmm $_POST['MMM'];
  $zuchtzulassung $_POST['Zuchtzulassung'];
  $titel $_POST['Titel'];
  $wertnote $_POST['Wertnote'];
  $nachweis $_POST['Nachweis'];
  $zurasse $_POST['ZuRasse'];
  $nachkommen $_POST['Nachkommen'];
  $decktaxe $_POST['Decktaxe'];
  $fotograf $_POST['Fotograf'];
  $fotolink $_POST['Fotolink'];
  $fotoanzahl $_POST['Fotoanzahl'];
  $fotos $_POST['Fotos'];
  
  //wenn eine der Variablen leer ist, dann [if]
   if( ($name=='') ) {
//Ausgabe der Fehlermeldung
      echo "<b>Error</b><br>
      Bitte fülle das Feld Name aus!<br><br>
      Bitte gehe <a href="javascript:%20history.back(-2)" target="_self">Zurück</a> und korrigiere dies.";
//wenn alles richtig ist: 
   } else {
//hier steht, was Eintrag ist und was damit gemacht werden soll. Welche Spalten sollen ausgefüllt werden?
      $eintrag "INSERT INTO `Pferd` ( `ID` , `Name` , `Rufname` , `Geburtstag` , `GebA` , `Geschlecht` , `Rasse` , `Farbe` , `STM` , `Besitzer` ,
                                        `Vorbesitzer` , `Züchter` , `Charakter` , `Verladefromm` , `Schmiedefromm` , `Turniererfahrung` , 
                                        `Geländesicher` , `Straßensicher` , `Temperament` , `DrAus` , `DrPot` , `SprAus` , `SprPot` , `VSAus` , 
                                        `VSPot` , `WAus` , `WPot` , `DiAus` , `DiPot` , `ReAus` , `RePot` , `FaAus` , `FaPot` , `VoAus` , `VoPot` , 
                                        `ASAus` , `ASPot` , `Pfleger` , `Trainer` , `Ausbilder` , `Turnierreiter` , `Gesamtgewinnsumme` , `Sachpreise` , 
                                        `V` , `VV` , `VVV` , `VVM` , `VM` , `VMV` , `VMM` , `M` , `MV` , `MVV` , `MVM` , `MM` , `MMV` , `MMM` , 
                                        `Zuchtzulassung` , `Titel` , `Wertnote` , `Nachweis` , `ZuRasse` , `Nachkommen` , `Decktaxe` , 
                                        `Fotograf` , `Fotolink` , `Fotoanzahl` , `Fotos` )
      VALUES ('', '$name', '$rufname', '$geburtstag', '$geba', '$geschlecht', '$rasse', '$farbe', '$stm', '$besitzer', '$vorbesitzer', '$züchter',
              '$charakter', '$verladefromm', '$schmiedefromm', '$turniererfahrung', '$geländesicher', '$straßensicher', '$temperament', '$draus',
              '$drpot', '$spraus', '$sprpot', '$vsaus', '$vspot', '$waus', '$wpot', '$diaus', '$dipot', '$reaus', '$repot', '$faaus', '$fapot',
              '$voaus', '$vopot', '$asaus', '$aspot', '$pfleger', '$trainer', '$ausbilder', '$turnierreiter', '$gesamtgewinnsumme', '$sachpreise',
              '$v', '$vv', '$vvv', '$vvm', '$vm', '$vmv', '$vmm', '$m', '$mv', '$mvv', '$mvm', '$mm', '$mmv', '$mmm', '$zuchtzulassung', '$titel',
              '$wertnote', '$nachweis', '$zurasse', '$nachkommen', '$decktaxe', '$fotograf', '$fotolink', '$fotoanzahl', '$fotos')";
      
//hier wird entschieden, dass $eintrag über die Datenbankverbindung eingetragen werden soll.
      $eintragen mysql_query($eintrag);
//Ausgabe der Erfolgsmeldung
      if($eintragen==true) {
         echo "Der Eintrag in die Tabelle war erfolgreich.<br><br><s>Weiterer Eintrag?</s>";
      } else {
         echo "Fehler!";
      }
   }
?>

  </body>
</html>


Ich würde mich über schnelle Hilfe freuen!

Liebe Grüße,
Marina
Marina347
Hä?
Hab ich da was nicht mitbekommen? *auf.dem.schlauch.steh*

Marina
Marina347
achso - vielen Dank!
Muss ich mir halt ein anderes Wort ausdenken Augenzwinkern

Marina
Marina347
So, hab mir jetzt was anderes ausgedacht - und es funktioniert immer noch nicht unglücklich
Melli
Hallo <:

Setzt doch mal "msql_error()" in das else, wo auch als echo dieses 'Fehler' angegeben wurde.
Dann müsste er dir eine Meldung geben, was schief gelaufen ist. Glaube ich zumindset.
Marina347
Zitat:
Parse error: syntax error, unexpected '}' in /usr/export/www/vhosts/funnetwork/hosting/rvaurora/php-Test/pferde_eintrage
n_send.php on line 112
Melli
Ähh, du musst hinter dem () noch ein ; machen.
Ansonsten wie normal halt, der Code
Marina347
achso ... hätte ich auch drauf kommen können ...

bin mir nicht sicher, ob ich es an die richtige stelle gesetzt hab. jetzt kommt auf jedenfall:
Zitat:
Fehler!
Fatal error: Call to undefined function msql_error() in /usr/export/www/vhosts/funnetwork/hosting/rvaurora/php-Test/pferde_eintrage
n_send.php on line 111
Melli
Mach mal die echo-Zeile so:
code:
1:
      echo 'Fehler: '.mysql_error().' <br> <a href="javascript:%20history.back(-2)" target="_self">Zurück</a>';
Marina347
Zitat:
Original von Melli
Mach mal die echo-Zeile so:
code:
1:
      echo 'Fehler: '.mysql_error().' <br> <a href="javascript:%20history.back(-2)" target="_self">Zurück</a>';


dann kommt das:
Zitat:
Fehler: '.mysql_error().'
Zurück


@ Mordred: Danke.
Marina347
*push*

Immernoch keine Lösung in Sicht *heul*
Marina347
Zitat:
Original von reiterhofmeeresblick
Ich würde die Echo-Zeile so machen

echo "Fehler: <br>"
echo mysql_error();
echo "<br> <br> <a href="java script:%20history.back(-2)" target="_self">Zurück</a>";

Mal zur Sicherheit xD


Dann kommt folgendes:
Zitat:
Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /usr/export/www/vhosts/funnetwork/hosting/rvaurora/php-Test/pferde_eintrage
n_send.php on line 110
1Sm!le
php:
1:
2:
3:
echo "Fehler: <br>";
echo mysql_error();
echo "<br> <br> <a href="javascript:%20history.back(-2)" target="_self">Zurück</a>";

wäre da korrekter.