Hi
My customer has a shoe store. I took over the hosting of this site about a year ago and have found that the previous web designer had a stock update script that could be run via cron. I've adjusted the database settings but I keep getting connection errors.
Here is the code
<?php
require'db_connect.php';
$arrLines = file('http://www.pleaserusa.com/download/Inv_stat.csv');
$arrLines = array_slice($arrLines, 1);
foreach ($arrLines as $line)
{
list($productCode, $size, $inStock) = explode(',',$line);
updateInsert($productCode, $size, $inStock);
}
function updateInsert($productCode, $size, $inStock)
{
if($inStock == '"YES"' || $inStock == '"LOW"')
{
$inStock = 1;
}
else
{
$inStock = 0;
}
$size = str_replace('"','', $size);
$sql_in = "REPLACE INTO tblPleaserStock (strProductCode, strSize, bolInStock) VALUES ($productCode, '$size', $inStock)";
mysql_query($sql_in) or die ("Error Inserting with query ".$sql_in);
$sql_up = "UPDATE tblPleaserStock SET bolInStock = $inStock WHERE strProductCode = $productCode AND strSize = '$size'";
mysql_query($sql_up) or die ("Error Updating with query ".$sql_up);
}
?>
and the error is
Warning: mysql_query() [function.mysql-query]: Access denied for user 'lingerie'@'localhost' (using password: NO) in /home/lingerie/public_html/scripts/update_stock.php on line 29
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/lingerie/public_html/scripts/update_stock.php on line 29
Error Inserting with query REPLACE INTO tblPleaserStock (strProductCode, strSize, bolInStock) VALUES ("AC103/B", '1', 1)
The database user is actually lingerie_zen and a password is set. The website is running on a standard cpanel server.
Any advice or help to get this script working correctly would be great.
Thanks
Bookmarks