Forum Moderators: coopster
I have a little problem. I have form:
<input name="0" type="text" value="1">
<input name="1" type="text" value="2">
<input name="2" type="text" value="3"> $value = $_POST["".$i.""];
$prikaz = "INSERT INTO cennik_moduly (limit,id_modulu,variant) VALUES ('$value','$id_moduly','$_POST[id]')";
$resultx = mysql_query($prikaz) or die (mysql_error()); use near 'limit,id_modulu,variant) VALUES ('1','1','')' at line 1
$value = $_POST["".$i.""];
$_POST[$i]. Even though $i might be an integer and your array indices are strings, PHP will handle the type conversion OK. HOWEVER, '0', '1' and '2' are not valid NAME attribute values. They should at least begin with a letter. 6.2 SGML basic types - ID and NAME [w3.org]
rocknbil:$prikaz = "INSERT INTO `cennik_moduly` (`limit`,`id_modulu`,`variant`) VALUES ('$value','$id_moduly','$_POST[id]')";
The other problem is the array reference inside double quotes. It will always be empty like that.
$value = 'ONE';
$id_moduly = 'TWO';
$_POST['id'] = 'THREE'; // 'id' (array index) must be quoted here
// 'id' (array index) must not be quoted whilst variable parsing using simple syntax
$prikaz = "INSERT INTO `cennik_moduly` (`limit`,`id_modulu`,`variant`)
VALUES ('$value','$id_moduly','$_POST[id]')";
echo $prikaz;
INSERT INTO `cennik_moduly` (`limit`,`id_modulu`,`variant`) VALUES ('ONE','TWO','THREE')