Title: error when running a query
Last modified: August 19, 2016

---

# error when running a query

 *  [kathymac](https://wordpress.org/support/users/kathymac/)
 * (@kathymac)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/error-when-running-a-query/)
 * Hello,
 * I have created a plugin that is suppose to add a new record to a
    new table I
   created in my WordPress database.
 * However, when I run the query shown below I get the following error:
 * “Invalid query: Access denied for user ‘apache’@’localhost’ (using password: 
   NO)”
 *  $sSQL = “INSERT INTO wp_product_info “;
    $sSQL .= “(“; $sSQL .= “ProdNum, ProdName,
   ProdDesc, “; $sSQL .= “ProdRegPrice, ProdSalePrice, “; $sSQL .= “Available, OnSale,
   ProdPic “; $sSQL .= “) “; $sSQL .= “VALUES “; $sSQL .= “(“; $sSQL .= ” ‘$sProdNum’,‘
   $sProdName’, ‘$sProdDesc’, “; $sSQL .= ” $sTemp1, $sTemp2, “; $sSQL .= ” ‘$sAvailable’,‘
   $sOnSale’, ” “; $sSQL .= “) “;
 *  $iResult = mysql_query($sSQL);
 *  if (! $iResult)
    { die (‘Invalid query: ‘ . mysql_error()); } else { print (“
   record inserted”); }
 * How do I fix this?

The topic ‘error when running a query’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [kathymac](https://wordpress.org/support/users/kathymac/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/error-when-running-a-query/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
