데이터를 데이터베이스에 삽입하는 코드가 있지만 구문을 여러 번 확인했지만이 오류가 계속 발생하는 경우 누구든지 도움을받을 수 있습니다. 나를?
오류 :SQL 구문에 오류가 있습니다.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cou ?','output','input','new line', 'break','output','Multiable_Choise')' at line 4
<?php
$connectdb = mysql_connect('localhost','root','sara', true) or die ("Not Connect");
if (!$connectdb)
{
die('Could not connect :'. mysql_errno());
}
$selestdb = mysql_select_db('iexa', $connectdb) or die ("not selected database");
$chois_1 = array();
$chois_2 = array();
$chois_3 = array();
$chois_4 = array();
$Question = array();
$correct = array();
$correct['Correct_Answer']= mysql_real_escape_string($_POST['Correct_Answer']) ;
$Question['Question']= mysql_real_escape_string($_POST['Question']) ;
$chois_1['Choise_1']= mysql_real_escape_string($_POST['Choise_1']) ;
$chois_2['Choise_2']= mysql_real_escape_string($_POST['Choise_2']) ;
$chois_3['Choise_3'] = mysql_real_escape_string($_POST['Choise_3']) ;
$chois_4['Choise_4'] = mysql_real_escape_string($_POST['Choise_4']) ;
if (isset($_POST['E_No'])) {
$E_no = $_POST['E_No'];
}
if (isset($_REQUEST['courseID'])) {
$courseId = $_REQUEST['courseID'];
}
$sql ="INSERT INTO question_bank (C_ID ,E_No , Question , Choise_1 , Choise_2 , Choise_3 , Choise_4 , Correct_Answer
, Question_Type)
VALUES
('$courseId','$E_no', {$Question['Question']}','{$chois_1['Choise_1']}','{$chois_2['Choise_2']}','{$chois_3['Choise_3']}',
'{$chois_4['Choise_4']}','{$correct['Correct_Answer']}','$_POST[Question_Type]')
";
if (!mysql_query($sql,$connectdb))
{
die ('Error :'.mysql_error());
}
echo "The Qustion is saved";
echo ' <br />
<a href="question.htm" >Add Another Question</a> <br />
<a href="ManageStudents.htm">Manage Students</a> <br />
<a href="Instructor.htm">Home</a>
';
mysql_close($connectdb);
?>
조언 앞에없는 : 당신은 아마 눈치 챘으로, (무엇보다도) 오류 메시지 상태 행 번호. 이는 매우 유용한 정보이며 쿼리를 작성하는 방법에 대한 힌트입니다. 줄을 많이 만들면 오류를 쉽게 찾을 수 있습니다. 물론, 합리적인 방법으로. – bostaf
테이블의 구조를 말씀해 주시겠습니까? 아마도 C_ID와 E_NO는 정수이고 문자열을이 필드에 삽입하려고합니다. – Virendra