Archiv verlassen und diese Seite im Standarddesign anzeigen : Invalid argument supplied for foreach()
mark2911
04.06.2006, 16:47:01
Hi,
ich erhalte aus einem Formular per POST Daten und will diese in eine Datenbank schreiben.
Ich erhalte nun folgende Fehlermeldung.
Warning: Invalid argument supplied for foreach() in /mnt/cr1/07/811/00000011/htdocs/Tippen.php on line 9
Was ist falsch in der Zeile neun?
[<?php
include("include/var.inc.php");
$tipps = $_POST["score_a"];
$teilnehmer = $_POST["id_teilnehmer"];
$spielt = $_POST["id_spieltag"];
$id_match = 1;
$db = mysql_connect($dbserver, $dbuser, $dbpass);
$insert = "INSERT INTO wm_tipps (id_match, id_teilnehmer, score_t1, id_spieltag) VALUES ('$id_match', '$teilnehmer', '$var', '$spielt')";
foreach($tipps as $var){
mysql_select_db($dbname, $db);
mysql_query($insert);
mysql_close($db);
$id_match = $id_match + 1;
}
?>
Danke für Eure Hilfe.
Gruß
Markus
Opendix
04.06.2006, 17:19:54
ist $tipps ein array?
mark2911
04.06.2006, 17:24:52
Ich dachte schon.
Die Daten werden über ein Formular übergeben.
Es sollten folgende Werte übergeben werden:
8 Werte für score_a
8 Werte für score_b
1 Wert für id_spieltag
1 Wert für id_teilnehmer
<form action="Tippen.php" method="POST">
<table align="left" border="0" width="350" cellspacing="0" cellpadding="3">
<colgroup>
<col width="160">
<col width="5">
<col width="160">
<col width="10">
<col width="5">
<col width="10">
</colgroup>
<tr>
<td align="right"><?php echo TEAM_A1; ?></td><td> - </td><td align="left"><?php echo TEAM_A2; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_A3; ?></td><td> - </td><td align="left"><?php echo TEAM_A4; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_B1; ?></td><td> - </td><td align="left"><?php echo TEAM_B2; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_B3; ?></td><td> - </td><td align="left"><?php echo TEAM_B4; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_C1; ?></td><td> - </td><td align="left"><?php echo TEAM_C2; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_C3; ?></td><td> - </td><td align="left"><?php echo TEAM_C4; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_D1; ?></td><td> - </td><td align="left"><?php echo TEAM_D2; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
<td align="right"><?php echo TEAM_D3; ?></td><td> - </td><td align="left"><?php echo TEAM_D4; ?></td>
<td><input type="text" name="score_a" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
<td> : </td>
<td><input type="text" name="score_b" size="1" style="width:40" maxlength="2" value="<? echo $form->value("user"); ?>"></td>
</tr>
<tr>
</tr>
<tr><td>
<input type="hidden" name="id_spieltag" value="S1">
<input type="hidden" name="id_teilnehmer" value="$session->username">
<input type="submit" value="Abgeben/Ändern"></td></tr>
</td></tr>
<tr><td colspan="2" align="left"><br></a></td></tr>
</table>
</form>
vBulletin® v3.8.3, Copyright ©2000-2024, Jelsoft Enterprises Ltd.