Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in E:\wamp\www\inventory\admin\dashboard\insert_export.php on line 94
i understand the error but how to correct the error, can anyone suggest me with explanation.
<?php
include 'connection/db_connection.php';
$row_data = array();
foreach($_POST['productname'] as $row=>$productname) {
$date=$_POST['datetime'];
$subject=$_POST['subject'];
$productname=mysql_real_escape_string($con,$productname);
$itemcode=mysql_real_escape_string($con,($_POST['itemcode'][$row]));
$quantity=mysql_real_escape_string($con,($_POST['quantity'][$row]));
$row_data[] = "('$date','$productname', '$itemcode', '$quantity','$subject')";
}
if (!empty($row_data))
{
$sql = 'INSERT INTO admin_export(datetime, product_name, item_code,quantity,subject) VALUES '.implode(',', $row_data);
$result = mysql_query($sql );
if ($result)
echo 'Successful inserts: ' . mysql_affected_rows($con);
else
echo 'query failed' ;
}
?>