Jump to content

Existing working website has problems on new server


Recommended Posts

Apologies in advance if this is the wrong place - either here or PHP Coding Help but I don't think this is a code issue...

 

I'll try to keep this simple initially to see what (if any) responses I get. I know it’s impossible to solve but some hints or ideas of what it could be would help  :D.

 

The problem is a website I have been given to host and it runs differently on different web servers and I wonder how to troubleshoot this issue because I have run out of ideas  :confused:.

 

  • It is my job to upload a website and ensure it works for the company I work for (given source code and DB).
  • I have a php shared hosting server with bluehost (personal).
  • Initially I uploaded it to my test server as a quick prototype and it worked ok.
  • My company used united hosting for hosting for the website.
  • I uploaded the website and DB to united hosting.

 

On the united hosting version of the website I have a few problems.

 

The problems are trivia because I cannot provide all the source code (300MB of it) but relate to when adding items to the basket (ecommerce website) nothing happens. Also something really weird happens when reading session values on a page - they are not returned on one page but are on another. So something is going wrong to do with the sessions and posting forms. Checking this functionality on the current live website and on my test website shows it works ok so it can't be the code. What makes this even weirder is that at one point it did work for a day or so and then stopped!

 

Initially I thought it may be some code discrepancies so I reverted to the original code so that it is the same as that on the working original live website and on my working test server but it still does not work.

 

So any ideas how I can go about solving this problem? I am more used to .NET and IIS than I am PHP so maybe it could be a setting in the php ini file? If this is the ONLY thing it could be then at least I know where to focus all my attention.

 

If it helps, I have 3 versions of the phpinfo.php from the 3 different servers (from the original live working website, from my working test server and from the new server with problems) but unsure of exactly what to check for. I could also go into much more technical detail providing code snippets that do not work should someone think they can / want to help

 

Many thanks for any help / advice  :)

 

Link to comment
Share on other sites

It would be useful to see a few snippets of the code just to get an idea of what sort of standards are employed, also seeing the active php.ini would be helpful. The most common issues that I've seen effecting code portability are short_open_tags, magic_quotes_gpc and register_globals.

Link to comment
Share on other sites

Add output_buffering, register_long_arrays, and session_register... to cags' list.

 

This can be a problem with the the code if the code is using old out of date methods (in some cases things that were depreciated 7 years ago.)

 

To troubleshoot, pick ONE problem at a time and find out why the code is exhibiting the symptom.

 

It is always best to fix code rather than to turn on the offending setting. Many of the settings that cags and I posted have been completely removed in upcoming php6, so getting the code up to current standards now, will prevent you or someone else from wasting even more time in the  future fixing it  -

 

short_open_tags - should never be used because they can be turned off

 

magic_quotes_gpc - all the magic quote settings have been removed in php6

 

register_globals - removed in php6

 

output_buffering - should not be relied on to fix code (should only be used if you want to buffer output)

 

register_long_arrays - the long array names have been removed in php6

 

session_register/session_is_registered/session_unregister - removed in php6

 

Link to comment
Share on other sites

Cheers for the suggestions, wasn't expecting such prompt replies and it gives me something to investigate over Christmas :).

 

cags - I just realised I have not got the php.ini for the active website (perhaps this is something I need from the existing hosting company of the working website?) - but I have the output from the phpinfo.php for what it is worth (attached). I'm guessing I'll need to compare this with my versions to help eliminate the problems.

Thanks PFMaBiSmAd - I wasn't aware of potential php6 problems and hope some of those settings hold a clue to why the code is exhibiting the symptoms.

 

cags, ok I'll list some code. I'm sure if you have a really quick scan through it you would have a better idea than me as to the standards used and I would appreciate any honest comments (I didn't write it and don't know what framework, if any, it uses).

 

3 files relating to a particular problem I have noticed:

 

inc\modules\ecommerce\ecommerce_functions.php

inc\modules\ecommerce\minibasket_rpc.php

inc\modules\ecommerce\product_details.php

 

In ecommerce_functions.php there are two functions used by the other pages:

 

<?php
function get_price($product_id, $account_type){

if($account_type != ""){
	$sql = "SELECT p.price, p.sale_price, p.price_vat_type AS price_vat, p.sale_price_vat_type AS sale_price_vat FROM 

_ecommerce_product_price p			WHERE p.account_type = '".$account_type."' AND p.product_id = '".$product_id."'";
	$result = mysql_query($sql);
	if(mysql_num_rows($result) > 0){
		$price_details = mysql_fetch_assoc($result);
	}else{
		$error = true;
	}
}

if($account_type == "" || $error){
	$sql = "SELECT p.default_price AS price, p.default_sale_price AS sale_price, p.default_price_vat AS price_vat, 

p.default_sale_price_vat AS			sale_price_vat FROM _ecommerce_products p WHERE p.id = '".$product_id."'";
	$result = mysql_query($sql);
	if(mysql_num_rows($result) > 0){
		$price_details = mysql_fetch_assoc($result);
	}
}
return $price_details;
}
?>

 

<?php
function calculate_product_price($this_key="", $orig_product_id, $charge_vat=1){

list($vat_value, $vat_numerator, $vat_denominator) = mysql_fetch_row(mysql_query("SELECT value, numerator, denominator 

FROM _ecommerce_vat WHERE active = '1'"));

if(is_numeric($this_key)){
	$orig_product_id = $_SESSION['ECOM_BASKET'][$this_key]['prod_id'];
}
$product_id = $orig_product_id;

$this_price_details = get_price($product_id, $_SESSION['reg_account_type']);

$sql = "SELECT stock_control FROM _ecommerce_products WHERE id ='".$product_id."'";
$stock_result = mysql_query($sql);
if(mysql_num_rows($stock_result) > 0){
	$is_stock_control_product = mysql_result($stock_result,0);
}
$sql = "SELECT type_id FROM _ecommerce_products WHERE id ='".$product_id."'";
$type_result = mysql_query($sql);
if(mysql_num_rows($type_result) > 0){
	$product_type = mysql_result($type_result,0);
}

if($_SESSION['ECOM_SETTINGS']['stock_control'] == 1 && $is_stock_control_product == 1){
	$stock_left = update_stock($product_id);
}

if($_SESSION['account_type']==""){
	$where_account_type = "AND account_type = '0'";
}else{
	$where_account_type = "AND account_type = '".$_SESSION['account_type']."' OR account_type = '0'";
}

.... etc
?>

 

minibasket_rpc.php shows a basket summary on the left of the website:

 

<?php

session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/config.php");
include($_SERVER['DOCUMENT_ROOT']."/inc/functions.php");
include($_SERVER['DOCUMENT_ROOT']."/inc/modules/ecommerce/ecommerce_functions.php");

function html2rpc($in) {
	$out = $in;
	$out = eregi_replace("\n|\r", "", $out);
	$out = addslashes($out);
	return $out;
}

switch($_GET['action']) {

	case 'show':

#			if(count($_SESSION['ECOM_BASKET']) > 0){
			$template = getFile($_SERVER

['DOCUMENT_ROOT']."/inc/modules/ecommerce/templates/mini_basket_header.html");
			$template_row = getFile($_SERVER

['DOCUMENT_ROOT']."/inc/modules/ecommerce/templates/mini_basket_row.html");
			$template_footer = getFile($_SERVER

['DOCUMENT_ROOT']."/inc/modules/ecommerce/templates/mini_basket_footer.html");

			if(is_array($_SESSION['ECOM_BASKET']) && count($_SESSION['ECOM_BASKET'])>0){
				$num_prods = count($_SESSION['ECOM_BASKET']);
				$keys = array_keys($_SESSION['ECOM_BASKET']);
				for($i=0;$i<count($_SESSION['ECOM_BASKET']);$i++){
					$attributes = "";
					$this_key = $keys[$i];
					$orig_product_id = $_SESSION['ECOM_BASKET'][$this_key]['prod_id'];
					$product_id = $orig_product_id;

					$result = mysql_query("SELECT id, name, link, category_id, parent_product_id FROM 

_ecommerce_products WHERE id = '".$product_id."' AND active='1' AND is_purchasable='1'");
					if(mysql_num_rows($result) > 0){

						$price_details = calculate_product_price($this_key,$orig_product_id);
						$num_items = $num_items + $_SESSION['ECOM_BASKET'][$this_key]['qty'];
						$final_price = $price_details['final_price'] + $final_price;

					}else{
						$to_remove[] = $this_key;
					}
				}
			}

			for($i=0;$i<count($to_remove);$i++){
				$sql = "SELECT name FROM _ecommerce_products WHERE id = '".$_SESSION['ECOM_BASKET']

[$to_remove[$i]]['prod_id']."'";
				$result = mysql_query($sql);
				if(mysql_num_rows($result) > 0){
					$product_name = mysql_result($result,0);
					print("alert('".html2rpc("'".$product_name."' is no longer available for 

purchasing!")."');");
				}
				$sql = "DELETE FROM _ecommerce_basket WHERE session_id = '".session_id()."' AND product_id 

= '".$_SESSION['ECOM_BASKET'][$to_remove[$i]]['prod_id']."'";
				mysql_query($sql);
				unset($_SESSION['ECOM_BASKET'][$to_remove[$i]]);
			}

			$template_row = str_replace("[NUM_ITEMS]","x".number_format($num_items),$template_row);
			$template_row = str_replace("[TOTAL_PRICE]",number_format($final_price,2),$template_row);
			$template_row = str_replace("[bASKET_LINK]","/".$_SESSION['ECOM_SETTINGS']

['shopping_link']."/your_basket/",$template_row);
			$template .= $template_row;

			#$template_footer = str_replace("[FULL_BASKET]","<a href=\"/".$_SESSION['ECOM_SETTINGS']

['shopping_link']."/your_basket/\">View Full Basket</a>",$template_footer);
			$template .= $template_footer;
#			}else{
#				$template = "";
#			}
		$template = html2rpc($template);		
		print("document.getElementById('mini_basket').innerHTML = '".$template."';if(document.getElementById

('your_basket')){yourBasket('show');}");
	break;

	case 'remove':
		if($_SESSION['reg_user_id']){
			$sql = "DELETE FROM _ecommerce_basket WHERE product_id = '".$_GET['id']."' AND account_id = 

".$_SESSION['reg_user_id']." AND session_id = '".session_id()."'";
			$result = mysql_query($sql);
		}
		$keys = array_keys($_SESSION['ECOM_BASKET']);
		for($i=0;$i<count($_SESSION['ECOM_BASKET']);$i++){
			$this_key = $keys[$i];
			if($_SESSION['ECOM_BASKET'][$this_key]['prod_id'] == $_GET['id']){
				unset($_SESSION['ECOM_BASKET'][$this_key]);
				$removed = true;
			}
		}

		print("miniBasket('show');");
		break;
}

?>

 

product_details.php lists the product details with the option to add to basket. Here is the main function:

 

<?php
function product_details($_GET, $_POST, $_SERVER, $r, $args, $specific=FALSE){

$last_working_category = calculate_category_id($args,$category_id);

#	print($link_array);


$test = calculate_link($args);
$link = calculate_category($args);
$sql = "SELECT id, name, link, default_price, category_id, type_id, default_sale_price, on_sale, description, 

is_purchasable, default_price_vat, default_sale_price_vat, active, views, stock_status, meta_keywords, meta_description, isbn, 

product_code FROM _ecommerce_products WHERE link = '".mysql_real_escape_string($link)."' AND category_id = 

'".$last_working_category."'";
#	print($sql."<br /><br />".$test);
#print("<br /><br />".$test-$link);
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0){
	$is_real_product = true;
	$product_details = mysql_fetch_assoc($result);	

	####################
	## Category Check ##
	####################

	$category_link = mysql_result(mysql_query("SELECT link FROM _ecommerce_categories WHERE id = 

'".mysql_real_escape_string($product_details['category_id'])."'"),0);
	$this_category_link_array = explode("/",ltrim(rtrim($test,"/"),"/"));
	array_pop($this_category_link_array);
	$this_category_link = "/".implode("/",$this_category_link_array)."/";	
	if(strtolower($this_category_link) == strtolower($category_link)){
		$is_real_category = true;
	}else{
		$is_real_category = false;
	}
}else{
	$is_real_product = false;
	$this_category_link_array = explode("/",ltrim(rtrim($test,"/"),"/"));
	array_pop($this_category_link_array);
	$this_category_link = "/".implode("/",$this_category_link_array)."/";
	$sql = "SELECT id FROM _ecommerce_categories WHERE link = '".$this_category_link."'";
	$result = mysql_query($sql);
	if(mysql_num_rows($result) > 0){
		$is_real_category = true;
	}else{
		$is_real_category = false;
	}	
}

if($is_real_category && $is_real_product){

	// Update the number of views
	if(!in_array($product_details['id'],$_SESSION['ecommerce']['viewed_products'])){
		$_SESSION['ecommerce']['viewed_products'][] = $product_details['id'];
		$views = $product_details['views'] + 1;
		mysql_query("UPDATE _ecommerce_products SET views = '".mysql_real_escape_string($views)."' WHERE id = 

'".mysql_real_escape_string($product_details['id'])."'");
	}		

	$currency = mysql_result(mysql_query("SELECT sign FROM _ecommerce_currency WHERE id = '".mysql_real_escape_string

($_SESSION['ECOM_SETTINGS']['currency_id'])."'"),0);

	// Main Product Image
	$result = mysql_query("SELECT id, alt_text, is_lead_image, source FROM _ecommerce_product_images WHERE product_id 

= '".mysql_real_escape_string($product_details['id'])."'");
	$i=0;
	if(mysql_num_rows($result) > 0){
		while($row = mysql_fetch_assoc($result)){
			if($i == 0){
				$image = $row['source'];
			}
			if($row['is_lead_image'] == 1){
				$image = $row['source'];				
			}
			$i++;
		}
	}else{
		$image = $_SESSION['ECOM_SETTINGS']['default_product_image'];
	}


	$result = mysql_query("SELECT id, name, link, product_details_template FROM _ecommerce_product_types WHERE id = 

'".mysql_real_escape_string($product_details['type_id'])."'");
	if(mysql_num_rows($result) > 0){
		$type_details = mysql_fetch_assoc($result);
		$details_template = getFile($_SERVER['DOCUMENT_ROOT']."/inc/modules/ecommerce/templates/".$type_details

['product_details_template']);
		switch($type_details['link']){
			case "bundle":
				if($product_details['description'] != ""){
					$product_details['description'] .= "<br />";
				}

				$sql = "SELECT product_bundle_id, qty FROM _ecommerce_product_bundle WHERE bundle_id 

='".$product_details['id']."'";
				$result = mysql_query($sql);
				if(mysql_num_rows($result) > 0){
					// Get link and name
					$bundle_details .= "<br /><table class='product_bundle' width='300px'>";
					$bundle_details .= "[bUNDLE_DETAILS_HEADER]";
					while($row = mysql_fetch_row($result)){
						$orig_product_id = $row[0];
						$product_id = $orig_product_id;

						$price_details = calculate_product_price("",$product_id, $charge_vat=1);

						// Need to check stock here, then do a calculation to see how many bundles 

can be created. Then update the bundle record accordingly!

						if($row['on_sale']==1){
							$product_price = $price_details['sale_price_vat'];
							$product_price_was = $price_details['price_vat'];
						}else{
							$product_price = $price_details['price_vat'];
						}

						$seperately_purchased_price = ($product_price * $row[1]) + 

$seperately_purchased_price;							

						$link_details = mysql_fetch_row(mysql_query("SELECT c.link, p.link, 

p.name, p.parent_product_id FROM _ecommerce_categories c, _ecommerce_products p WHERE p.id = '".$product_id."' AND (c.id = 

p.category_id OR p.category_id = 0) AND p.active = '1'"));

						if($link_details[3] != "0"){
							$parent_details = mysql_fetch_array(mysql_query("SELECT p.id, 

p.name, p.link, c.link FROM _ecommerce_products p, _ecommerce_categories c WHERE p.id = '".$link_details[3]."' AND (c.id = 

p.category_id OR p.category_id = 0) AND p.active = '1'"));
							$link_details[0] = $parent_details[3];
							$link_details[1] = $parent_details[2];
							$link_details[2] = $parent_details['name'] . " - 

<small>".$link_details[2]."</small>";
						}

						$image_result = mysql_query("SELECT id, alt_text, is_lead_image, source 

FROM _ecommerce_product_images WHERE product_id = ".$product_id);
						$i=0;
						if(mysql_num_rows($image_result) > 0){
							while($image_row = mysql_fetch_assoc($image_result)){
								if($i == 0){
									$bundle_image = $image_row['source'];
								}
								if($row['is_lead_image'] == 1){
									$bundle_image = $image_row['source'];			


								}
								$i++;
							}
						}else{
							$bundle_image = $_SESSION['ECOM_SETTINGS']

['default_product_image'];
						}

						$bundle_details .= "<tr valign='top'>";
						$bundle_details .= "<td><img src='/inc/thumbnailer.php?

src=images/products/" .$bundle_image. "&width=30&height=30' /></td>";
						$bundle_details .= "<td width='100%'><a href='/" .$_SESSION

['ECOM_SETTINGS']['shopping_link']. "/go_shopping" .$link_details[0]. $link_details[1]."/'>" .$link_details[2]."</a></td>";
						$bundle_details .= "<td> (x".$row[1].")</td>";
						$bundle_details .= "</tr>";

					}
					$bundle_details .= "</table>";
				}
				$bundle_details = str_replace("[bUNDLE_DETAILS_HEADER]","<tr valign='top'><th 

colspan='3'>Purchased Individually Total = £".number_format($seperately_purchased_price,2)."</th>",$bundle_details);

				$details_template = str_replace("[bUNDLE_DETAILS]",$bundle_details,$details_template);

				break;

			case "sub_product":
				$sql = "SELECT id, name, description, active, on_sale, is_purchasable, stock_status, 

product_code FROM _ecommerce_products WHERE parent_product_id = '".$product_details['id']."' AND active='1'";
				$result = mysql_query($sql);
				if(mysql_num_rows($result) > 0){
					$sub_product_details .= "<table cellpadding='5' cellspacing='0' border='0' 

class='sub_products' align='left'>";
					$sub_product_details .= "<tr valign='top'><th> </th><th>Name</th><th>Product 

Code</th><th>Description</th><th>Price</th><th>Buy</th></tr>";
					while($row = mysql_fetch_assoc($result)){

						$sql = "SELECT stock_control FROM _ecommerce_products WHERE id ='".$row

['id']."'";
						$stock_result = mysql_query($sql);
						if(mysql_num_rows($stock_result) > 0){
							$is_stock_control_product = mysql_result($stock_result,0);
						}


						$price_details = get_price($row['id'], $_SESSION['reg_account_type']);
						$img_result = mysql_query("SELECT id, alt_text, is_lead_image, source FROM 

_ecommerce_product_images WHERE product_id = ".$row['id']);
						if(mysql_num_rows($img_result) > 0){
							while($img_row = mysql_fetch_assoc($img_result)){
								$sub_image = $img_row['source'];
							}
						}else{
							$sub_image = $_SESSION['ECOM_SETTINGS']['default_product_image'];
						}

						$price_details = calculate_product_price("",$row['id'], $charge_vat=1);

						if($row['on_sale']==1){
							$product_price = "£".number_format($price_details

['sale_price_vat'],2);
							$product_price_was = "<small>Was £".number_format

($price_details['price_vat'],2)."</small>";
						}else{
							$product_price = "£".number_format($price_details

['price_vat'],2);
						}

						$rules_result = mysql_query("SELECT id, rule, description, qty, new_price 

FROM _ecommerce_product_rules WHERE product_id = '".$row['id']."' ORDER BY qty DESC");
						if(mysql_num_rows($rules_result) > 0){
							$rules = "<br /><span style='color: #ff0000;'>";
							while($rule_row = mysql_fetch_assoc($rules_result)){
								$rule_value = mysql_result(mysql_query("SELECT name FROM 

_ecommerce_product_rules_values WHERE id = '".$rule_row['rule']."'"),0);
								$rules .= "<br />If quantity ".$rule_value." ".$rule_row

['qty']." then new price is £".number_format($rule_row['new_price'],2).".";
							}
							$rules .= "</span>";
						}
						$this_buy = "<form name=\"buy_product\" method=\"POST\" action=\"[ACTION]

\" style=\"margin:0px;\"><input size='1' type='text' id='qty' name='qty'  value='1' /> <input type=\"submit\" name=\"buy\" 

id=\"buy\" value=\"Buy Now!\"  style=\"background-color:#b61bb2; color:gray; font-weight:bold; padding:0px; border: 1px solid 

#000000;\" onclick=\"if(confirm('Are you sure you wish to purchase this product?')){}else{return false;}\"><input type='hidden' 

name='prod_id' id='prod_id' value='" .$row['id']. "' /></form>";
						if($_SESSION['ECOM_SETTINGS']['stock_control'] == 1 && 

$is_stock_control_product == 1){
							switch($row['stock_status']){
								case "0":
									$this_buy .= "<br /><span style='color: 

".$_SESSION['ECOM_SETTINGS']['stock_ok_colour']."; font-weight: bold;'>In Stock</span>";
									break;
								case "1":
									$this_buy .= "<br /><span style='color: 

".$_SESSION['ECOM_SETTINGS']['stock_warning_colour']."; font-weight: bold;'>Low in Stock</span>";
									break;
								case "2":
									$this_buy .= "<span style='color: ".$_SESSION

['ECOM_SETTINGS']['stock_warning_colour']."; font-weight: bold;'>Low in Stock</span>";
									break;
								case "3":
									$this_buy = "<span style='color: ".$_SESSION

['ECOM_SETTINGS']['stock_critical_colour']."; font-weight: bold;'>Out of Stock</span>";
									break;
							}
						}

						$size = getimagesize($_SERVER

['DOCUMENT_ROOT']."/images/products/".$sub_image);
						if($size[0] > 400 || $size[1] > 300){
							$size[0] = 400;
							$size[1] = 300;
						}

						$sub_product_details .= "<tr valign='top'><td align='center'><img 

alt='".$product_details['name']." :- ".$row['name']."' title='".$product_details['name']." :- ".$row['name']."' 

src='/inc/thumbnailer.php?src=images/products/" .$sub_image. "&width=125&height=125' /><br /><a href='' style='cursor: pointer;' 

onclick=\"window.open('/images/products/" .$sub_image. "','imagedisplay','width=".($size[0]+35).",height=".($size[1]

+35).",menubar=no,toobar=no,scrollbars=no,resizable=yes');return false;\"><img src='/images/magnifier.png' border='0' alt='View 

Larger Photograph' title='View Larger Photograph' /> View Larger</td><td>".$row['name']."</td><td>".$row

['product_code']."</td><td>".$row['description']."</td><td>".$product_price ." ".$product_price_was." ".$rules."</td><td 

width='120px'>".$this_buy."</td></tr>";
					}
					$sub_product_details .= "</table>";
				}else{
					$sub_product_details = "No Sub products";
				}
				$details_template = str_replace

("[sUB_PRODUCT_DETAILS]",$sub_product_details,$details_template);
				break;

			case "event":
				break;

			case "membership":
				break;
			case "donation":
				$donate = "<form name=\"buy_product\" method=\"POST\" action=\"[ACTION]\" 

style=\"margin:0px;\"><input size='1' type='text' id='qty' name='qty'  value='1' /> <input type=\"submit\" name=\"buy\" 

id=\"buy\" value=\"Donate\"    style=\"background-color:#a9c4f2; color: #ffffff; padding:0px; border: 1px solid #000000;\" 

onclick=\"if(confirm('Are you sure you wish to make a donation?')){}else{return false;}\"><input type='hidden' name='prod_id' 

id='prod_id' value='" .$product_details['id']. "' /></form>";
				$details_template=str_replace("[DONATE]",$donate,$details_template);
				break;
			case "book":
				$details_template=str_replace("[iSBN]",$product_details['isbn'],$details_template);
				break;
			default:
				break;
		}
	}		

	$price_details = calculate_product_price("",$product_details['id'], $charge_vat=1);

	if($product_details['on_sale']==1){
		$product_price = "£".number_format($price_details['sale_price_vat'],2);
		$product_price_was = "<small>Was £".number_format($price_details['price_vat'],2)."</small>";
	}else{
		$product_price = "£".number_format($price_details['price_vat'],2);
	}

	if($product_details['is_purchasable'] == 1){
		$rules_result = mysql_query("SELECT id, rule, description, qty, new_price FROM _ecommerce_product_rules 

WHERE product_id = '".$product_details['id']."' ORDER BY qty DESC");
		if(mysql_num_rows($rules_result) > 0){
			$rules .= "<span style='color: #ff0000;'>";
			while($rule_row = mysql_fetch_assoc($rules_result)){
				$rule_value = mysql_result(mysql_query("SELECT name FROM _ecommerce_product_rules_values 

WHERE id = '".$rule_row['rule']."'"),0);
				$rules .= "<br />If quantity ".$rule_value." ".$rule_row['qty']." then new price is 

£".number_format($rule_row['new_price'],2).".";
			}
			$rules .= "</span>";
		}
		if($product_details['active'] == '1'){

			$sql = "SELECT stock_control FROM _ecommerce_products WHERE id ='".$product_details['id']."'";
			$stock_result = mysql_query($sql);
			if(mysql_num_rows($stock_result) > 0){
				$is_stock_control_product = mysql_result($stock_result,0);
			}
			if($_SESSION['ECOM_SETTINGS']['stock_control'] == 1 && $is_stock_control_product == 1){
				if($price_details['stock_left'] == 0){
					$buy = "<br /><span style='color: ".$_SESSION['ECOM_SETTINGS']

['stock_critical_colour']."; font-weight: bold;'>Out of Stock</span>";
				}else{
					$buy = "<form name=\"buy_product\" method=\"POST\" action=\"[ACTION]\" 

style=\"margin:0px;\"><input size='1' type='text' id='qty' name='qty'  value='1' /> <input type=\"submit\" name=\"buy\" 

id=\"buy\" value=\"Buy Now!\"    style=\"background-color:#a9c4f2; color:gray;font-weight:bold;  padding:0px; border: 1px solid 

#000000;\" onclick=\"if(confirm('Are you sure you wish to purchase this product?')){}else{return false;}\"><input type='hidden' 

name='prod_id' id='prod_id' value='" .$product_details['id']. "' /></form>";	
					switch($product_details['stock_status']){
						case "0":
							$buy .= "<br /><span style='color: ".$_SESSION['ECOM_SETTINGS']

['stock_ok_colour']."; font-weight: bold;'>In Stock</span>";
							break;
						default:
							$buy .= "<br /><span style='color: ".$_SESSION['ECOM_SETTINGS']

['stock_warning_colour']."; font-weight: bold;'>Low in Stock</span>";
							break;
					}
				}
			}else{
				$buy = "<form name=\"buy_product\" method=\"POST\" action=\"[ACTION]\" 

style=\"margin:0px;\"><input size='1' type='text' id='qty' name='qty'  value='1' /> <input type=\"submit\" name=\"buy\" 

id=\"buy\" value=\"Buy Now!\"   style=\"background-color:#a9c4f2; color:gray; font-weight:bold; padding:0px; border: 1px solid 

#000000;\" onclick=\"if(confirm('Are you sure you wish to purchase this product?')){}else{return false;}\"><input type='hidden' 

name='prod_id' id='prod_id' value='" .$product_details['id']. "' /></form>";	
			}

		}else{
			$buy = "<br /><span style='color: #ff0000; font-weight: bold;'>Currently inactive for 

purchasing</span>";
		}
	}else{			
		list($page_id, $page_link, $page_parent) = mysql_fetch_row(mysql_query("SELECT id, link, parent FROM 

content WHERE content LIKE \"%[CONTACTFORM]%\" AND system=0 AND active=1;"));
		$url =  buildUrl($page_id);
		$buy = "<br /><span style='color: #ff0000; font-weight: bold;'>Please <a href='".$url."' style='color: 

#ff0000; font-weight: bold;'>contact us</a> for more details or call us on 0845 456 1866</span>";
	}	

	$associated_products = associated_products($product_details['id']);
	$also_purchased = also_purchased($product_details['id']);
	$allowed=(check_cordons($product_details['category_id']));
	if(!$allowed)
	{
		$buy="";
		$product_price="";
	}
	$template = getFile($_SERVER['DOCUMENT_ROOT']."/inc/modules/ecommerce/templates/product_detail.html");
	$template = str_replace("[PRODUCT_DETAILS]",$details_template,$template);
	$template = str_replace("[PRODUCT_CODE]",$product_details['product_code'],$template);
	$template = str_replace("[PRICE]",$product_price,$template);
	$template = str_replace("[PRICE_WAS]",$product_price_was,$template);
	$template = str_replace("[bUY]",$buy,$template);
	$template = str_replace("[sELLER_ID]",$user_details['username'],$template);

	$template = str_replace("[DESCRIPTION]",stripslashes($product_details['description']),$template);
	$image= str_replace("&","%26",$image);
	$template = str_replace("[iMAGE]","<img alt='".$product_details['name']."' title='".$product_details['name']."' 

src='/inc/thumbnailer.php?src=images/products/" .$image. "&width=" .$_SESSION['ECOM_SETTINGS']['product_image_width']. 

"&height=".$_SESSION['ECOM_SETTINGS']['product_image_height']. "' />",$template);
	$template = str_replace("[ALSO_PURCHASED]",$also_purchased,$template);
	$template = str_replace("[ASSOCIATED_PRODUCTS]",$associated_products,$template);
	$template = str_replace("[ACTION]","/".$_SESSION['ECOM_SETTINGS']

['shopping_link']."/your_basket/add_to_basket/",$template);
	$template = str_replace("[iD]",$product_details['id'],$template);



}elseif($is_real_category){
	$template = "<p>This product does not exist.</p>";
}else{
	$template = "???";
}

$to_return['content'] = $template;
$to_return['meta_keywords'] = $product_details['meta_keywords'];
$to_return['meta_description'] = $product_details['meta_description'];

return $to_return;
}
?>

 

Cheers guys

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Setting error_reporting to E_ALL and display_errors to ON will probably help by exposing all the php errors that might be occurring. Check that these two settings actually get changed by checking the phpinfo() output.

 

The phpinfo() output is actually more valuable than the actual php.ini because it shows the actual settings, which can be modified by http.conf, .htaccess, and local php.ini files and the possibility that the php.ini that you are looking at is not the one that php is using.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.