This is my form, a pretty simple one. I have 3 text fields in which questions will be entered and i want to put each of these in a database.
questFormtest.php:
<html>
<head><title> Test Quest</title></head>
<body>
<form id= "qform" method="post" action="quest.php">
<h3>Enter Questions</h3><br><br>
<h3>Question 1: Five marks each.<br></h3>
a) <input type="text" name="field1[][field1]" size=45>* <br><br>
b) <input type="text" name="field1[][field1]" size=45>* <br><br>
c) <input type="text" name="field1[][field1]" size=45>* <br><br>
<p><input type="submit" name="submit" value="Submit" align="center" />
<input type='reset' name='Cancel' value='Cancel' /></p>
</form>
</body>
</html>
My php file is as follows:
quest.php:
<?php
include('connectionfile.php');
$cnt = count($_POST['field1']);
if ($cnt > 0) {
$insertArr = array();
for ($i=0; $i<$cnt; $i++) {
$insertArr[] = "('" .$_POST['field1'][$i]. "')";
}
$query = "INSERT INTO paper (field1) VALUES " . implode(", ", $insertArr);
mysql_query($query) or trigger_error("Insert failed: " . mysql_error());
}
mysql_close($id_link);
?>
When i run the file, it gives me the following error:
Insert failed: Unknown column 'field1' in 'field list' in quest.php on line 15
Can somebody tell me if there's an error in the query and how i can solve it? Any help is appreciated :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…