This is the js\jquery function which is requesting
function AssignWork(){
var projectId = $jq(".dmProjName").val(),
empId = $jq(".nameEmp").val(),
assignWork = $jq(".workDescription").val(),
workDate = $jq(".workDate").val();
var go_path = "Employee_Switch_Person.php?action=assignWork&vars=4&var1="+empId+"&var2="+projectId+"&var3="+assignWork+"&var4="+workDate;
$jq.get(go_path,{},function(data){
if(data ==1){
alert("Successfully Assigned!");
showAssignWork(0);
}
});
}
this is php
function assignWork($empId,$projectId,$assignWork,$workDate){
//echo $workDate;
global $con;
date_default_timezone_set("Asia/Karachi");
//echo "date format".date('Y-m-d H:i:s');
//echo $empId.",".$projectId.",".$assignWork.",".$workDate;
$sql = "INSERT INTO `tblempassignwork` (`EmpId`, `AssignWork`, `AssignById`, `ProjectId`, `WorkDate`, `AssignDateTime`)
VALUES($empId,'".$assignWork."',".$_COOKIE["userID"].",".$projectId.",'".$workDate."','".date('Y-m-d H:i:s')."')";
$result = mysql_query($sql,$con) or die(mysql_error());
echo $result;
}
problem is that
assignWork = $jq(".workDescription").val()
can contain a string with double quote, single quote, hash or any special character. if i use single quote or hash then it is showing
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 's and makes some examples',3,77,'2015-05-08','2015-05-08 09:51:17')' at line 2
cause i have type single quote in string. so how can i skip special character when passing through get request.