Here is my code..i am trying to make an ajax application..this is my insertion code..when i send requests to this from my client side java script page, insertion is made to the data base by this php code avording to the reuest sent from the client side java script..when i insert by static array for testing insertion works fine..but when ever i send dynamic dynamic $_POST array from client side javascript it show mysql syntax error..Please if some one can help..
O ..这是我编辑的段..它更紧凑..但同样的问题..显示mysql语法错误..在第1行..我不知道什么时候staticaly测试这个PHP
文件工作正常..但是当从客户端javascript通过ajax运行它显示
furstrating mysql语法error.thanks提前..
include('db_constant.php');
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
function insert_into($post_array)
{
$conn = new mysqli(HOST,USER,PASSWORD,WBUT_MAIN);
/* check connection */
if (mysqli_connect_errno())
{
die( mysqli_connect_error());
}
else
{
$outp='';
$college_name='';
$college_name.= $post_array['clg_frm'].'_result';
//echo $college_name;
$sgpa="";$cgpa="";$ygpa="";
//$post_array[8]=(int)$post_array[8];
//echo $post_array[0];
$post_array['C_O']=(int)$post_array['C_O'];
echo $post_array['C_O'];
$query='INSERT INTO '.$college_name.'(wbut_reg_no,wbut_roll_no,fastname,lastname,stream,degree,semestar,suba,subano,sub2_code,sub2_no,sub3_code,sub3_no,sub4_code,sub4_no,sub5_code,sub5_no,sub6_code,sub6_no,sub7_code,sub7_no,';
$query.='sub8_code,sub8_no,sub9_code,sub9_no,sub10_code,sub10_no,sub11_code,sub11_no,sub12_code,sub12_no,sgpa,cgpa,ygpa)';
$query.='VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
//echo $query;
echo "<br/><br/><br/>";
$stmt=$conn->prepare($query);
echo $conn->error;
$stmt->bind_param('sssssisisisisisisisisisisisisisss',$post_array['reg_frm'],$post_array['roll_frm'],$post_array['fast_frm'],
$post_array['last_frm'],$post_array['dept_frm'],$post_array['degree_frm'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],
$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O']
,$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O']
,$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O']
,$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O'],$post_array['C_O']);
//echo $stmt->error;
$result=$stmt->execute();
if($result)
$outp='[{"status":"success","id":"'.$post_array['clg_frm'].'"}]';
else
$outp='[{"status":"failure"}]';
echo $outp;
}
/* close connection */
$conn->close();
}
$array_post=array();
$array_post=$_POST;
//foreach ($_POST as $key => $value)
// {
// $array_post[$key]=$value;
//$index_value[$i]=$value;
//$i++;
//}
// $_POST=array('reg_frm'=>'2','clg_frm'=>'george_college');
print_r($_POST);
insert_into($array_post);
//print_r($array_post);
?>