It gets the information from an http remote call on Mals Ecommerce (if you are familiar with that). It adds to the order table and even sends back the message "done" when set to debug but it just won't update the inventory.
I am really new to this so can anybody help???? Pleeeeeze
<?php
//Update the inventory
// username
$user = "bla";
// password
$pass = "blabla";
// database to query
$db = "blablabla";
// open a connection to the database
$connection = mysql_connect(localhost, $user, $pass) or
die("Invalid server
or user");
mysql_select_db($db) or die("Unable to select database $DBName");
mysql_query("REPLACE INTO orders (username,id,ip,date,method,cart,discount,subtotal,shipping,tax,total,shipping_zone,inv_name,inv_company,inv_addr1,inv_addr2,inv_state,inv_zip,inv_country,tel,fax,email,message)
VALUES ('$username',$id,'$ip','$order_date','$method','$cart','$discount','$subtotal','$shipping','$tax','$total',$shipping_zone,'$inv_name','$inv_company','$inv_addr1','$inv_addr2','$inv_state','$inv_zip','$inv_country','$tel','$fax','$email','$message')");
// Parse cart variable from order into an array of chunks based on the : character
$carts=$cart;
$items = explode ("~", $carts);
for ($i = 0; $i < sizeof($items); $i++){
$fields = explode (" : ", $items[$i]);
$query = "select Inventory from Shop_Items where Item = '$fields[0]'";
$result = mysql_db_query($db, $query, $connection) or die("Error in query");
$numOfRows = mysql_num_rows ($result);
$inventory = mysql_fetch_row($result);
$final = $inventory[0]-$fields[1];
if ($final < 1){
$update = "update Shop_Items set OutOfStock = 'Yes' where Item = '$fields[0]'" or die ("Error in query");
$result = mysql_query($update,$connection) or die("Error in query");
}
$query = "update Shop_Items set Inventory = '$final' where Item = '$fields[0]'";
$result = mysql_query($query,$connection) or die("Error in
query");
}
?>
Done
😕