Below is the code being used to generate the code to be executed inside the mysql_query function
for($i=1;$i<=$totalcols;$i++) {
$val_array[] = "\'\".\$data->val(\$i,$i).\"\'";
}
the array above is then converted into string without slashes using implode and stripslashes function.
$val = stripslashes(implode(",",$val_array));
And all of it produces a string as follows
'".$data->val($i,1)."','".$data->val($i,2)."','".$data->val($i,3)."'
This is the string that I am using inside the VALUES() . Instead of executing the code and then inserting the values in database, the string is being inserted into the database as it is.The mysql_query function is being used as follows.
mysql_query("INSERT INTO import_excel ($val_string) VALUES($val)") or die(mysql_error());
Here is screenshot if data inserted into DB
