title: Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in
body: <p>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</p>
  
  <p>i understand the error but how to correct the error, can anyone suggest me with explanation.</p>
  
  <pre><code>&lt;?php 
  include 'connection/db_connection.php';    
  $row_data = array();
  foreach($_POST['productname'] as $row=&gt;$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' ;
  } 
  
  
  ?&gt;
  </code></pre>