Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

automated stock reordering contrib


Guest

Recommended Posts

Posted

I created a stock reordering system for our site that works a treat. We sell about 1200 items a month from multiple suppliers and ordering was a nightmare prior to the program. I have been packaging it up as a contrib but have a snag with one of the modules under php5. It craps out with the blurb 'supplied argument not a valid mysql result resource'. I think it is due to the way I'm using the array?

 

Works fine on php4.. Any ideas welcome...

 

This is a snippet of the offending bit of code. $text is the order number to start from.

 

 

$conn = mysql_connect($server, $user, $password);
mysql_select_db($database, $conn) or die (mysql_error());

$sql = "select `*` from `orders_products` where `orders_id` >= $text";
$index = mysql_query($sql, $conn);
$rawdata = array();

$i = "0";

while ($array = mysql_fetch_array($index)) {   ------------------------------------------------------------------ craps out here on php5 - works fine on php4

$sql = "select `*` from `products` where `products_id` = $array[products_id]";
$records = mysql_query($sql, $conn);

while ($result = mysql_fetch_array($records)) {

	if ($array[products_id] == $result[products_id]) {

		$rawdata[$i][0] = $result[products_model];

	}

}

$rawdata[$i][1] = $array[products_name];
$rawdata[$i][2] = $array[products_quantity];

$sql = "select `*` from `orders` where `orders_id` = $array[orders_id]";
$records = mysql_query($sql, $conn);

while ($result = mysql_fetch_array($records)) {

	if ($result[orders_status] != "3") {

		$rawdata[$i][3] = "Order " . $result[orders_id];

		} else {

		$rawdata[$i][3] = "Stock";

		}

	}

$i++;

}


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...