• 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.