Solved

Parse and Update Query

Posted on 2011-03-17
4
168 Views
Last Modified: 2012-05-11
Here is the final script.  It is pretty big.  Basically it:
1.  parses a feed
2. Compares the feed data to the data in the DB.
3. Updates the DB with the info in the Feed.
4. Reports what fields were different between the DB and feed.

The problem is it won't update or report if the the field is empty in the DB or empty in the field.

Please have a look:

<?php 
// CONNECT AND SELECT THE DATA BASE
set_error_handler ('oops'); 

// custom error handler 
function oops($type, $msg, $file, $line, $context) { 
	switch ($type) { 
// notices 
	case E_NOTICE: 
	break; 
// warnings 
	case E_WARNING: 
// report error 
	print "Non-fatal error on line $line of $file: $msg <br />"; 
	break; 
// other 
	default: 
	print "Error of type $type on line $line of $file: $msg <br />"; 
	break; 
	} 
} 
error_reporting(E_ALL);
?>
<html>
<head>
<title>Update and Report</title>
<style>
body	{
	background-color:#D9DCF0;
}

h3	{
	display:inline;
}

h4	{
	font-family:Arial, Helvetica, sans-serif;
	font-size:15px;
	font-weight:700;
	color:#003300;
	display:inline;
}

fieldset	{
	border:double 5px #333333;
	padding:9px;
}

fieldset fieldset	{
	border:solid 3px #000000;
	padding:9px;
	background-color:#ffffff;
}

fieldset fieldset fieldset	{
	border:double 5px #000000;
	padding:13px;
	background-color:#D9DCF0;
}

#wrapper	{
	width:850px;
	padding:20px;
	margin:0px auto 0px auto;
}

.content	{
	font-family:Arial, Helvetica, sans-serif;
	font-size:13px;
	font-weight:600;
	color:#000000;
}

.green	{
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	font-weight:600;
	color:#009900;
}

.bold	{
	font-family:Arial, Helvetica, sans-serif;
	font-size:15px;
	font-weight:600;
	color:#000000;
}



</style>
</head>

<body>

<!--  WRAPPER  -->
<div id="wrapper" class="content">
<?php
echo "<h1>Update and Report</h1><br /><br />
*** To asure proper results, <h3>Please do not</h3> press any keys while this function is processing. ***<br /><br />
<fieldset>";

// THE CLASS DEFINITION TO HOLD THE CHANGELOG DATA FIELDS


class Changes
{
	protected $prodNo, $old_brand, $old_bridge, $old_bridgePickup, $old_buyCodeUSA, $old_prodColor, $old_prodDisplayName, $old_prodMsrp, $old_prod_part_number, $old_prod_upc, $old_casegigbag, $old_controlKnobs, $old_controls, $old_fingerBoardRadius, $old_fretSize, $old_headstock, $old_height, $old_id, $old_includedAccessories, $old_legalese, $old_length, $old_bodyShape, $old_neckMaterial, $old_neckPlate, $old_neckShape, $old_numFrets, $old_nutWidth, $old_originCountry, $old_picks, $old_pickupConfiguration, $old_pickupSwitching, $old_polishingCloth, $old_positionInlays, $old_prodId, $old_prodSubType, $old_prodType, $old_prod_brand, $old_prodLongDesc, $old_prodName, $old_prodNo, $old_subBrand, $old_productDisplayRank, $old_productLine, $old_adjWrench, $old_scaleLength, $old_series, $old_seriesDisplayRank,$old_strapButtons, $old_stringNut, $old_strings, $old_subBrndDisRank, $old_switchTip, $old_tremoloArmHandle, $old_trussRodNut, $old_trussRodWrench, $old_tuningMachines, $old_uniqueFeatures, $old_volume, $old_isConDisp, $old_catalogText, $old_additonalComments, $old_fretboard, $old_hardware, $old_middlePickup, $old_neckPickup, $new_brand, $new_bridge, $new_bridgePickup, $new_buyCodeUSA, $new_prodColor, $new_prodDisplayName, $new_prodMsrp, $new_prod_part_number, $new_prod_upc, $new_casegigbag, $new_controlKnobs, $new_controls, $new_fingerBoardRadius, $new_fretSize, $new_headstock, $new_height, $new_id, $new_includedAccessories, $new_legalese, $new_length, $new_bodyShape, $new_neckMaterial, $new_neckPlate, $new_neckShape, $new_numFrets, $new_nutWidth, $new_originCountry, $new_picks, $new_pickupConfiguration, $new_pickupSwitching, $new_polishingCloth, $new_positionInlays, $new_prodId, $new_prodSubType, $new_prodType, $new_prod_brand, $new_prodLongDesc, $new_prodName, $new_prodNo, $new_subBrand, $new_productDisplayRank, $new_productLine, $new_adjWrench, $new_scaleLength, $new_series, $new_seriesDisplayRank, $new_strapButtons, $new_stringNut, $new_strings, $new_subBrndDisRank, $new_switchTip, $new_tremoloArmHandle, $new_trussRodNut, $new_trussRodWrench, $new_tuningMachines, $new_uniqueFeatures, $new_volume, $new_isConDisp, $new_catalogText, $new_additonalComments, $new_fretboard, $new_hardware, $new_middlePickup, $new_neckPickup; 


//  CONSTRUCT PRODUCT NUMBER  //
   	public function __construct($prodNo)
    {
    	$this->prodNo = $prodNo;
		$this->old_brand = NULL;
		$this->old_bridge = NULL;
		$this->old_bridgePickup = NULL;
		$this->old_buyCodeUSA = NULL;
		$this->old_prodColor = NULL;
		$this->old_prodDisplayName = NULL;
		$this->old_prodMsrp = NULL;
		$this->old_prod_part_number = NULL;
		$this->old_prod_upc = NULL;
		$this->old_casegigbag = NULL;
		$this->old_controlKnobs= NULL;
		$this->old_controls= NULL;
		$this->old_fingerBoardRadius= NULL;
		$this->old_fretSize= NULL;
		$this->old_headstock= NULL;
		$this->old_height= NULL;
		$this->old_id= NULL;
		$this->old_includedAccessories= NULL;
		$this->old_legalese= NULL;
		$this->old_length= NULL;
		$this->old_bodyShape= NULL;
		$this->old_neckMaterial= NULL;
		$this->old_neckPlate= NULL;
		$this->old_neckShape= NULL;
		$this->old_numFrets= NULL;
		$this->old_nutWidth= NULL;
		$this->old_originCountry= NULL;
		$this->old_picks= NULL;
		$this->old_pickupConfiguration= NULL;
		$this->old_pickupSwitching= NULL;
		$this->old_polishingCloth= NULL;
		$this->old_positionInlays= NULL;
		$this->old_prodId= NULL;
		$this->old_prodSubType= NULL;
		$this->old_prodType= NULL;
		$this->old_prod_brand= NULL;
		$this->old_prodLongDesc= NULL;
		$this->old_prodName= NULL;
		$this->old_subBrand= NULL;
		$this->old_productDisplayRank= NULL;
		$this->old_productLine= NULL;
		$this->old_adjWrench= NULL;
		$this->old_scaleLength= NULL;
		$this->old_series= NULL;
		$this->old_seriesDisplayRank= NULL;
		$this->old_strapButtons= NULL;
		$this->old_stringNut= NULL;
		$this->old_strings= NULL;
		$this->old_subBrndDisRank= NULL;
		$this->old_switchTip= NULL;
		$this->old_tremoloArmHandle= NULL;
		$this->old_trussRodNut= NULL;
		$this->old_trussRodWrench= NULL;
		$this->old_tuningMachines= NULL;
		$this->old_uniqueFeatures= NULL;
		$this->old_volume= NULL;
		$this->old_isConDisp= NULL;
		$this->old_catalogText= NULL;
		$this->old_additonalComments= NULL;
		$this->old_fretboard= NULL;
		$this->old_hardware= NULL;
		$this->old_middlePickup= NULL;
		$this->old_neckPickup= NULL;
		

		$this->new_brand = NULL;
		$this->new_bridge = NULL;
		$this->new_bridgePickup = NULL;
		$this->new_buyCodeUSA= NULL;
		$this->new_prodColor= NULL;
		$this->new_prodDisplayName= NULL;
		$this->new_prodMsrp = NULL;
		$this->new_prod_part_number = NULL;
		$this->new_prod_upc = NULL;
		$this->new_casegigbag = NULL;
		$this->new_controlKnobs= NULL;
		$this->new_controls= NULL;
		$this->new_fingerBoardRadius= NULL;
		$this->new_fretSize= NULL;
		$this->new_headstock= NULL;
		$this->new_height= NULL;
		$this->new_id= NULL;
		$this->new_includedAccessories= NULL;
		$this->new_legalese= NULL;
		$this->new_length= NULL;
		$this->new_bodyShape= NULL;
		$this->new_neckMaterial= NULL;
		$this->new_neckPlate= NULL;
		$this->new_neckShape= NULL;
		$this->new_numFrets= NULL;
		$this->new_nutWidth= NULL;
		$this->new_originCountry= NULL;
		$this->new_picks= NULL;
		$this->new_pickupConfiguration= NULL;
		$this->new_pickupSwitching= NULL;
		$this->new_polishingCloth= NULL;
		$this->new_positionInlays= NULL;
		$this->new_prodId= NULL;
		$this->new_prodSubType= NULL;
		$this->new_prodType= NULL;
		$this->new_prod_brand= NULL;
		$this->new_prodLongDesc= NULL;
		$this->new_prodName= NULL;
		$this->new_subBrand= NULL;
		$this->new_productDisplayRank= NULL;
		$this->new_productLine= NULL;
		$this->new_adjWrench= NULL;
		$this->new_scaleLength= NULL;
		$this->new_series= NULL;
		$this->new_seriesDisplayRank= NULL;
		$this->new_strapButtons= NULL;
		$this->new_stringNut= NULL;
		$this->new_strings= NULL;
		$this->new_subBrndDisRank= NULL;
		$this->new_switchTip= NULL;
		$this->new_tremoloArmHandle= NULL;
		$this->new_trussRodNut= NULL;
		$this->new_trussRodWrench= NULL;
		$this->new_tuningMachines= NULL;
		$this->new_uniqueFeatures= NULL;
		$this->new_volume= NULL;
		$this->new_isConDisp= NULL;		
		$this->new_catalogText= NULL;
		$this->new_additonalComments= NULL;
		$this->new_fretboard= NULL;

		$this->new_hardware= NULL;
		$this->new_middlePickup= NULL;
		$this->new_neckPickup= NULL;
    }
//  END CONSTRUCT PRODUCT NUMBER  //


//  BRAND  FUNCTION  //
	public function set_brand($old_brand, $new_brand)
    {
		$this->old_brand = $old_brand;
		$this->new_brand = $new_brand;
    }
	
//  BRIDGE  FUNCTION  //
	public function set_bridge($old_bridge, $new_bridge)
    {
		$this->old_bridge = $old_bridge;
		$this->new_bridge = $new_bridge;
    }

//  BRIDGE PICKUP  FUNCTION  //
	public function set_bridgePickup($old_bridgePickup, $new_bridgePickup)
    {
		$this->old_bridgePickup = $old_bridgePickup;
		$this->new_bridgePickup = $new_bridgePickup;
    }

//  BUY CODE FUNCTION  //
	public function set_buyCodeUSA($old_buyCodeUSA, $new_buyCodeUSA)
    {
		$this->old_buyCodeUSA = $old_buyCodeUSA;
		$this->new_buyCodeUSA = $new_buyCodeUSA;
    }


//  COLOR FUNCTION  //
	public function set_prodColor($old_prodColor, $new_prodColor)
    {
		$this->old_prodColor = $old_prodColor;
		$this->new_prodColor = $new_prodColor;
    }
    

//  DISPLAY NAME FUNCTION  //
	public function set_prodDisplayName($old_prodDisplayName, $new_prodDisplayName)
    {
		$this->old_prodDisplayName = $old_prodDisplayName;
		$this->new_prodDisplayName = $new_prodDisplayName;
    }

//  MSRP FUNCTION  //
	public function set_prodMsrp($old_prodMsrp, $new_prodMsrp)
    {
		$this->old_prodMsrp = $old_prodMsrp;
		$this->new_prodMsrp = $new_prodMsrp;
    }

//  PART NUMBER FUNCTION  //
	public function set_prod_part_number($old_prod_part_number, $new_prod_part_number)
    {
		$this->old_prod_part_number = $old_prod_part_number;
		$this->new_prod_part_number = $new_prod_part_number;
    }

//  PART NUMBER FUNCTION  //
	public function set_prod_upc($old_prod_upc, $new_prod_upc)
    {
		$this->old_prod_upc = $old_prod_upc;
		$this->new_prod_upcr = $new_prod_upc;
    }

//  GIG BAG FUNCTION  //
	public function set_casegigbag($old_casegigbag, $new_casegigbag)
    {
		$this->old_casegigbag = $old_casegigbag;
		$this->new_casegigbag = $new_casegigbag;
    }	

//  CONTROL KNOBS FUNCTION  //
	public function set_controlKnobs($old_controlKnobs, $new_controlKnobs)
    {
		$this->old_casegigbag = $old_controlKnobs;
		$this->new_controlKnobs = $new_controlKnobs;
    }	

//  CONTROLS FUNCTION  //
	public function set_controls($old_controls, $new_controls)
    {
		$this->old_controls = $old_controls;
		$this->new_controls = $new_controls;
    }
	
//  FINGER BOARD RADIUS FUNCTION  //
	public function set_fingerBoardRadius($old_fingerBoardRadius, $new_fingerBoardRadius)
    {
		$this->old_fingerBoardRadius = $old_fingerBoardRadius;
		$this->new_fingerBoardRadius = $new_fingerBoardRadius;
    }

//  FRET SIZE FUNCTION  //
	public function set_fretSize($old_fretSize, $new_fretSize)
    {
		$this->old_fretSize = $old_fretSize;
		$this->new_fretSize = $new_fretSize;
    }
	
//  HEADSTOCK FUNCTION  //
	public function set_headstock($old_headstock, $new_headstock)
    {
		$this->old_headstock = $old_headstock;
		$this->new_headstock = $new_headstock;
    }

//  HEIGHT FUNCTION  //
	public function set_height($old_height, $new_height)
    {
		$this->old_height = $old_height;
		$this->new_height = $new_height;
    }			

//  ID FUNCTION  //
	public function set_id($old_id, $new_id)
    {
		$this->old_id = $old_id;
		$this->new_id = $new_id;
    }

//  ACCESSORIES FUNCTION  //
	public function set_includedAccessories($old_includedAccessories, $new_includedAccessories)
    {
		$this->old_includedAccessories = $old_includedAccessories;
		$this->new_includedAccessories = $new_includedAccessories;
    }

//  LEGALESE FUNCTION  //
	public function set_legalese($old_legalese, $new_legalese)
    {
		$this->old_legalese = $old_legalese;
		$this->new_legalese = $new_legalese;
    }

//  LENGTH FUNCTION  //
	public function set_length($old_length, $new_length)
    {
		$this->old_length = $old_length;
		$this->new_length = $new_length;
    }	

//  BODY SHAPE FUNCTION  //
	public function set_bodyShape($old_bodyShape, $new_bodyShape)
    {
		$this->old_bodyShape = $old_bodyShape;
		$this->new_bodyShape = $new_bodyShape;
    }

//  NECK MATERIAL FUNCTION  //
	public function set_neckMaterial($old_neckMaterial, $new_neckMaterial)
    {
		$this->old_neckMaterial = $old_neckMaterial;
		$this->new_neckMaterial = $new_neckMaterial;
    }

//  NECK PLATE FUNCTION  //
	public function set_neckPlate($old_neckPlate, $new_neckPlate)
    {
		$this->old_neckPlate = $old_neckPlate;
		$this->new_neckPlate = $new_neckPlate;
    }

//  NECK SHAPE FUNCTION  //
	public function set_neckShape($old_neckShape, $new_neckShape)
    {
		$this->old_neckShape = $old_neckShape;
		$this->new_neckShape = $new_neckShape;
    }

//  FRETS FUNCTION  //
	public function set_numFrets($old_numFrets, $new_numFrets)
    {
		$this->old_numFrets = $old_numFrets;
		$this->new_numFrets = $new_numFrets;
    }	

//  NUT WIDTH FUNCTION  //
	public function set_nutWidth($old_nutWidth, $new_nutWidth)
    {
		$this->old_nutWidth = $old_nutWidth;
		$this->new_nutWidth = $new_nutWidth;
    }

//  COUNTRY FUNCTION  //
	public function set_originCountry($old_originCountry, $new_originCountry)
    {
		$this->old_originCountry = $old_originCountry;
		$this->new_originCountry = $new_originCountry;
    }

//  PICKS FUNCTION  //
	public function set_picks($old_picks, $new_picks)
    {
		$this->old_picks = $old_picks;
		$this->new_picks = $new_picks;
    }		

//  PICKUP CONFIG FUNCTION  //
	public function set_pickupConfiguration($old_pickupConfiguration, $new_pickupConfiguration)
    {
		$this->old_pickupConfiguration = $old_pickupConfiguration;
		$this->new_pickupConfiguration = $new_pickupConfiguration;
    }

//  PICKUP SWITCHING FUNCTION  //
	public function set_pickupSwitching($old_pickupSwitching, $new_pickupSwitching)
    {
		$this->old_pickupSwitching = $old_pickupSwitching;
		$this->new_pickupSwitching = $new_pickupSwitching;
    }

//  POLISHING CLOTH FUNCTION  //
	public function set_polishingCloth($old_polishingCloth, $new_polishingCloth)
    {
		$this->old_polishingCloth = $old_polishingCloth;
		$this->new_polishingCloth = $new_polishingCloth;
    }

//  PPOSITION INLAYS FUNCTION  //
	public function set_positionInlays($old_positionInlays, $new_positionInlays)
    {
		$this->old_positionInlays = $old_positionInlays;
		$this->new_positionInlays = $new_positionInlays;
    }
	
//  PRODUCT ID FUNCTION  //
	public function set_prodId($old_prodId, $new_prodId)
    {
		$this->old_prodId = $old_prodId;
		$this->new_prodId = $new_prodId;
    }	
	
//  SUB TYPE FUNCTION  //
	public function set_prodSubType($old_prodSubType, $new_prodSubType)
    {
		$this->old_prodSubType = $old_prodSubType;
		$this->new_prodSubType = $new_prodSubType;
    }	
			
//  PRODUCT TYPE FUNCTION  //
	public function set_prodType($old_prodType, $new_prodType)
    {
		$this->old_prodType = $old_prodType;
		$this->new_prodType = $new_prodType;
    }		

//  BRAND FUNCTION  //
	public function set_prod_brand($old_prod_brand, $new_prod_brand)
    {
		$this->old_prod_brand = $old_prod_brand;
		$this->new_prod_brand = $new_prod_brand;
    }

//  LONG DESC FUNCTION  //
	public function set_prodLongDesc($old_prodLongDesc, $new_prodLongDesc)
    {
		$this->old_prodLongDesc = $old_prodLongDesc;
		$this->new_prodLongDesc = $new_prodLongDesc;
    }
	
//  PRODUCT NAME FUNCTION  //
	public function set_prodName($old_prodName, $new_prodName)
    {
		$this->old_prodName = $old_prodName;
		$this->new_prodName = $new_prodName;
    }
	
//  PRODUCT NUMBER FUNCTION  //
	public function set_prodNo($old_prodNo, $new_prodNo)
    {
		$this->old_prodNo = $old_prodNo;
		$this->new_prodNo = $new_prodNo;
    }	


//  SUB BRAND FUNCTION  //
	public function set_subBrand($old_subBrand, $new_subBrand)
    {
		$this->old_subBrand = $old_subBrand;
		$this->new_subBrand = $new_subBrand;
    }		

//  DISPLAY RANK FUNCTION  //
	public function set_productDisplayRank($old_productDisplayRank, $new_productDisplayRank)
    {
		$this->old_productDisplayRank = $old_productDisplayRank;
		$this->new_productDisplayRank = $new_productDisplayRank;
    }

//  PRODUCT LINE FUNCTION  //
	public function set_productLine($old_productLine, $new_productLine)
    {
		$this->old_productLine = $old_productLine;
		$this->new_productLine = $new_productLine;
    }
//  WRENCH FUNCTION  //
	public function set_adjWrenche($old_adjWrench, $new_adjWrench)
    {
		$this->old_adjWrench = $old_adjWrench;
		$this->new_adjWrench = $new_adjWrench;
    }			

//  SCALE LENGTH FUNCTION  //
	public function set_scaleLength($old_scaleLength, $new_scaleLength)
    {
		$this->old_scaleLength = $old_scaleLength;
		$this->new_scaleLength = $new_scaleLength;
    }	
//  SCALE LENGTH FUNCTION  //
	public function set_series($old_series, $new_series)
    {
		$this->old_series = $old_series;
		$this->new_series = $new_series;
    }		
	
//  DISPLAY RANK FUNCTION  //
	public function set_seriesDisplayRank($old_seriesDisplayRank, $new_sseriesDisplayRank)
    {
		$this->old_seriesDisplayRank = $old_seriesDisplayRank;
		$this->new_seriesDisplayRank = $new_seriesDisplayRank;
    }		
	
//  BUTTONS FUNCTION  //
	public function set_strapButtons($old_strapButtons, $new_strapButtons)
    {
		$this->old_strapButtons = $old_strapButtons;
		$this->new_strapButtons = $new_strapButtons;
    }
	

//  STRING NUT FUNCTION  //
	public function set_stringNut($old_stringNut, $new_stringNut)
    {
		$this->old_stringNut= $old_stringNut;
		$this->new_stringNut= $new_stringNut;
    }

//  STRINGS FUNCTION  //
	public function set_strings($old_strings, $new_strings)
    {
		$this->old_strings= $old_strings;
		$this->new_strings= $new_strings;
    }
//  SUB DISPLAY RANK FUNCTION  //
	public function set_subBrndDisRank($old_subBrndDisRank, $new_subBrndDisRank)
    {
		$this->old_subBrndDisRank= $old_subBrndDisRank;
		$this->new_subBrndDisRank= $new_subBrndDisRank;
    }		

//  SWITCH TIP FUNCTION  //
	public function set_switchTip($old_switchTip, $new_switchTip)
    {
		$this->old_switchTip= $old_switchTip;
		$this->new_switchTip= $new_switchTip;
    }	

//  TREMOLO HANDLE FUNCTION  //
	public function set_tremoloArmHandle($old_tremoloArmHandle, $new_tremoloArmHandle)
    {
		$this->old_tremoloArmHandle= $old_tremoloArmHandle;
		$this->new_tremoloArmHandle= $new_tremoloArmHandle;
    }	
//  ROD NUT FUNCTION  //
	public function set_trussRodNut($old_trussRodNut, $new_trussRodNut)
    {
		$this->old_trussRodNut= $old_trussRodNut;
		$this->new_trussRodNut= $new_trussRodNut;
    }		
	
//  ROD WRENCH FUNCTION  //
	public function set_trussRodWrench($old_trussRodWrench, $new_trussRodWrench)
    {
		$this->old_trussRodWrench= $old_trussRodWrench;
		$this->new_trussRodWrench= $new_trussRodWrench;
    }		
			
//  TUNING MACHINE FUNCTION  //
	public function set_tuningMachines($old_tuningMachines, $new_tuningMachines)
    {
		$this->old_tuningMachines= $old_tuningMachines;
		$this->new_tuningMachines= $new_tuningMachines;
    }	

//  UNIQUE FEATURES FUNCTION  //
	public function set_uniqueFeatures($old_uniqueFeatures, $new_uniqueFeatures)
    {
		$this->old_uniqueFeatures= $old_uniqueFeatures;
		$this->new_uniqueFeatures= $new_uniqueFeatures;
    }

//  VOLUME FUNCTION  //
	public function set_volume($old_volume, $new_volume)
    {
		$this->old_volume= $old_volume;
		$this->new_volume= $new_volume;
    }	

//  DISPLAY FUNCTION  //
	public function set_isConDisp($old_isConDisp, $new_isConDisp)
    {
		$this->old_isConDisp= $old_isConDisp;
		$this->new_isConDisp= $new_isConDisp;
    }	


//  DISPLAY FUNCTION  //
	public function set_catalogText($old_catalogText, $new_catalogText)
    {
		$this->old_catalogText= $old_catalogText;
		$this->new_catalogText= $new_catalogText;
    }
		
//  ADD COMMENTS FUNCTION  //
	public function set_additonalComments($old_additonalComments, $new_additonalComments)
    {
		$this->old_additonalComments= $old_additonalComments;
		$this->new_additonalComments= $new_additonalComments;
    }

//  FRETBOARD FUNCTION  //
	public function set_fretboard($old_fretboard, $new_fretboard)
    {
		$this->old_fretboard= $old_fretboard;
		$this->new_fretboard= $new_fretboard;
    }	

//  HARDWARE FUNCTION  //
	public function set_hardware($old_hardware, $new_hardware)
    {
		$this->old_hardware= $old_hardware;
		$this->new_hardware= $new_hardware;
    }		

//  MIDDLE PICKUP FUNCTION  //
	public function set_middlePickup($old_middlePickup, $new_middlePickup)
    {
		$this->old_middlePickup= $old_middlePickup;
		$this->new_middlePickup= $new_middlePickup;
    }			
	
//  NECK PICKUP FUNCTION  //
	public function set_neckPickup($old_neckPickup, $new_neckPickup)
    {
		$this->old_neckPickup= $old_neckPickup;
		$this->new_neckPickup= $new_neckPickup;
    }



//  GET CHANGE MESSAGE  //
	public function get_change_message()  
    {
        // SET THE MESSAGE TO THE OBJECT'S prodNo ONLY
		$msg = $this->prodNo;


// ADD TO THE MESSAGE FOR ANY CHANGES



//  BRAND  //
       	if ($this->old_brand) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BRAND HAS CHANGED FROM<br />$this->old_brand<br />
				TO:<br />$this->new_brand</span><br />";
		}
		
//  BRIDGE  //
       	if ($this->old_bridge) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BRIDGE HAS CHANGED FROM<br />$this->old_bridge<br />
				TO:<br />$this->new_bridge</span><br />";
		}

//  BRIDGE PICKUP  //
       	if ($this->old_bridgePickup) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BRIDGE PICKUP HAS CHANGED FROM<br />$this->old_bridgePickup<br />
				TO:<br />$this->new_bridgePickup</span><br />";
		}

//  BUY CODE  //
       	if ($this->old_buyCodeUSA) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BUY CODE HAS CHANGED FROM<br />$this->old_buyCodeUSA<br />
				TO:<br />$this->new_buyCodeUSA</span><br />";
		}

//  COLOR  //
       	if ($this->old_prodColor) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE COLOR HAS CHANGED FROM<br />$this->old_prodColor<br />
				TO:<br />$this->new_prodColor</span><br />";
		}

//  DISPLAY NAME  //
       	if ($this->old_prodDisplayName) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE DISPLAY NAME HAS CHANGED FROM<br />$this->old_prodDisplayName<br />
				TO:<br />$this->new_prodDisplayName</span><br />";
		}

//  MSRP  //
       	if ($this->old_prodMsrp) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE MSRP HAS CHANGED FROM<br />$this->old_prodMsrp<br />
				TO:<br />$this->new_prodMsrp</span><br />";
		}

//  PART NUMBER  //
       	if ($this->old_prod_part_number) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PRODUCT PART NUMBER HAS CHANGED FROM<br />$this->old_prod_part_number<br />
				TO:<br />$this->new_prod_part_number</span><br />";
		}

//  UPC  //
       	if ($this->old_prod_upc) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE UPC HAS CHANGED FROM<br />$this->old_prod_upc<br />
				TO:<br />$this->new_prod_upc</span><br />";
		}

//  GIG BAG  //
       	if ($this->old_casegigbag) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE GIG BAG HAS CHANGED FROM<br />$this->old_casegigbag<br />
				TO:<br />$this->new_casegigbag</span><br />";
		}

//  CONTROL KNOB  //
       	if ($this->old_controlKnobs) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE CONTROL KNOB HAS CHANGED FROM<br />$this->old_controlKnobs<br />
				TO:<br />$this->new_controlKnobs</span><br />";
		}		

//  CONTROLS  //
       	if ($this->old_controls) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE CONTROLS HAVE CHANGED FROM<br />$this->old_controls<br />
				TO:<br />$this->new_controls</span><br />";
		}			

//  FINGER BOARD  //
       	if ($this->old_fingerBoardRadius) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE FINGER BOARD RADIUS HAS CHANGED FROM<br />$this->old_fingerBoardRadius<br />
				TO:<br />$this->new_fingerBoardRadius</span><br />";
		}			

//  FRET SIZE  //
       	if ($this->old_fretSize) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE FRET SIZE HAS CHANGED FROM<br />$this->old_fretSize<br />
				TO:<br />$this->new_fretSize</span><br />";
		}		

//  HEADSTOCK  //
       	if ($this->old_headstock) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE HEADSTOCK HAS CHANGED FROM<br />$this->old_headstock<br />
				TO:<br />$this->new_headstock</span><br />";
		}

//  HEIGHT  //
       	if ($this->old_height) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE HEIGHT HAS CHANGED FROM<br />$this->old_height<br />
				TO:<br />$this->new_height</span><br />";
		}		

//  id  //
       	if ($this->old_id) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE ID HAS CHANGED FROM<br />$this->old_id<br />
				TO:<br />$this->new_id</span><br />";
		}

//  ACCESSORIES  //
       	if ($this->old_includedAccessories) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE ACCESSORIES HAVE CHANGED FROM<br />$this->old_includedAccessories<br />
				TO:<br />$this->new_includedAccessories</span><br />";
		}

//  LEGALESE  //
       	if ($this->old_legalese) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE LEGALESE HAS CHANGED FROM<br />$this->old_legalese<br />
				TO:<br />$this->new_legalese</span><br />";
		}

//  LENGTH  //
       	if ($this->old_length) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE LENGTH HAS CHANGED FROM<br />$this->old_length<br />
				TO:<br />$this->new_length</span><br />";
		}		

//  BODY SHAPE  //
       	if ($this->old_bodyShape) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE BODY SHAPE HAS CHANGED FROM<br />$this->old_bodyShape<br />
				TO:<br />$this->new_bodyShape</span><br />";
		}				

//  NECK MATERIAL  //
       	if ($this->old_neckMaterial) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE NECK MATERIAL HAS CHANGED FROM<br />$this->old_neckMaterial<br />
				TO:<br />$this->new_neckMaterial</span><br />";
		}
	
//  NECK PLATE  //
       	if ($this->old_neckPlate) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE NECK PLATE HAS CHANGED FROM<br />$this->old_neckPlate<br />
				TO:<br />$this->new_neckPlate</span><br />";
		}	
		
//  NECKSHAPE  //
       	if ($this->old_neckShape) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE NECK SHAPE HAS CHANGED FROM<br />$this->old_neckShape<br />
				TO:<br />$this->new_neckShape</span><br />";
		}		

//  FRETS  //
       	if ($this->old_numFrets) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE FRETS HAS CHANGED FROM<br />$this->old_numFrets<br />
				TO:<br />$this->new_numFrets</span><br />";
		}		
	
//  NUT WIDTH  //
       	if ($this->old_nutWidth) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE NUT WIDTH HAS CHANGED FROM<br />$this->old_nutWidth<br />
				TO:<br />$this->new_nutWidth</span><br />";
		}	

//  COUNTRY  //
       	if ($this->old_originCountry) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE COUNTRY HAS CHANGED FROM<br />$this->old_originCountry<br />
				TO:<br />$this->new_originCountry</span><br />";
		}			

//  PICKS  //
       	if ($this->old_picks) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PICKS HAVE CHANGED FROM<br />$this->old_picks<br />
				TO:<br />$this->new_picks</span><br />";

		}

//  PICKUP CONFIG  //
       	if ($this->old_pickupConfiguration) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PICKUP CONFIG HAVE CHANGED FROM<br />$this->old_pickupConfiguration<br />
				TO:<br />$this->new_pickupConfiguration</span><br />";
		}

//  PICKUP SWITCHING  //
       	if ($this->old_pickupSwitching) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PICKUP SWITCHING HAS CHANGED FROM<br />$this->old_pickupSwitching<br />
				TO:<br />$this->new_pickupSwitching</span><br />";
		}		

//  POLISHING CLOTH  //
       	if ($this->old_polishingCloth) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE POLISHING CLOTH HAS CHANGED FROM<br />$this->old_polishingCloth<br />
				TO:<br />$this->new_polishingCloth</span><br />";
		}

//  INLAYS  //
       	if ($this->old_positionInlays) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\"><span class=\"green\">THE POSITION INLAYS HAVE CHANGED FROM<br />$this->old_positionInlaysh<br />
				TO:<br />$this->new_positionInlays</span><br />";
		}

//  PRODUCT ID  //
       	if ($this->old_prodId) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\"><span class=\"green\"THE PRODUCT ID HAS CHANGED FROM<br />$this->old_prodId<br />
				TO:<br />$this->new_prodId</span><br />";
		}

//  PRODUCT SUB TYPE  //
       	if ($this->old_prodSubType) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\"><span class=\"green\">THE PRODUCT SUB TYPE HAS CHANGED FROM<br />$this->old_prodSubType<br />
				TO:<br />$this->new_prodSubType</span><br />";
		}

//  PRODUCT TYPE  //
       	if ($this->old_prodType) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PRODUCT TYPE HAS CHANGED FROM<br />$this->old_prodType<br />
				TO:<br />$this->new_prodType</span><br />";
		}


//  BRAND  //
       	if ($this->old_prod_brand) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE BRAND HAS CHANGED FROM<br />$this->old_prod_brand<br />
				TO:<br />$this->new_prod_brand</span><br />";
		}		

//  LONG DESC  //
       	if ($this->old_prodLongDesc) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE LONG DESC HAS CHANGED FROM<br />$this->old_prodLongDesc<br />
				TO:<br />$this->new_prodLongDesc</span><br />";
		}		

//  PRODUCT NAME  //
       	if ($this->old_prodName) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PRODUCT NAME HAS CHANGED FROM<br />$this->old_prodName<br />
				TO:<br />$this->new_prodName</span><br />";
		}
		
//  PRODUCT NAME  //
       	if ($this->old_prodNo) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PRODUCT NUMBER HAS CHANGED FROM<br />$this->old_prodNo<br />
				TO:<br />$this->new_prodNo</span><br />";
		}		

//  SUB BRAND  //
       	if ($this->old_subBrand) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE SUB BRAND HAS CHANGED FROM<br />$this->old_subBrand<br />
				TO:<br />$this->new_subBrand</span><br />";
		}
//  DISPLAY RANK  //
       	if ($this->old_productDisplayRank) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE DISPLAY RANK HAS CHANGED FROM<br />$this->old_productDisplayRank<br />
				TO:<br />$this->new_productDisplayRank</span><br />";
		}
		
//  PRODUCT LINE  //
       	if ($this->old_productLine) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE PRODUCT LINE HAS CHANGED FROM<br />$this->old_productLine<br />
				TO:<br />$this->new_productLine</span><br />";
		}		
		
//  WRENCH  //
       	if ($this->old_adjWrench) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE WRENCH HAS CHANGED FROM<br />$this->old_adjWrench<br />
				TO:<br />$this->new_adjWrench</span><br />";
		}

//  SCALE LENGTH  //
       	if ($this->old_scaleLength) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE SCALE LENGTH HAS CHANGED FROM<br />$this->old_scaleLength<br />
				TO:<br />$this->new_scaleLength</span><br />";
		}

//  SERIES  //
       	if ($this->old_series) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE SERIES HAS CHANGED FROM<br />$this->old_series<br />
				TO:<br />$this->new_series</span><br />";
		}		

//  Display Rank  //
       	if ($this->old_seriesDisplayRank) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE SERIES DISPLAY RANK HAS CHANGED FROM<br />$this->old_seriesDisplayRank<br />
				TO:<br />$this->new_seriesDisplayRank</span><br />";
		}		
//  STRAP BUTTONS  //
       	if ($this->old_strapButtons) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE STRAP BUTTONS HAS CHANGED FROM<br />$this->old_strapButtons<br />
				TO:<br />$this->new_strapButtons</span><br />";
		}		

//  STRING NUT  //
       	if ($this->old_stringNut) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE STRING NUT HAS CHANGED FROM<br />$this->old_stringNut<br />
				TO:<br />$this->new_stringNut</span><br />";
		}

//  STRINGS  //
       	if ($this->old_strings) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE STRINGS HAVE CHANGED FROM<br />$this->old_strings<br />
				TO:<br />$this->new_strings</span><br />";
		}		
//  BRAND DISPLAY RANK  //
       	if ($this->old_subBrndDisRank) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE BRAND DISPLAY RANK HAS CHANGED FROM<br />$this->old_subBrndDisRank<br />
				TO:<br />$this->new_subBrndDisRank</span><br />";
		}	

//  SWITCH TIP  //
       	if ($this->old_switchTip) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE SWITCH TIP HAS CHANGED FROM<br />$this->old_switchTip<br />
				TO:<br />$this->new_switchTip</span><br />";
		}		

//  TREMOLO HANDLE  //
       	if ($this->old_tremoloArmHandle) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE TREMOLO HANDLE HAS CHANGED FROM<br />$this->old_tremoloArmHandle<br />
				TO:<br />$this->new_tremoloArmHandle</span><br />";
		}		
//  TRUSS ROD NUT  //
       	if ($this->old_trussRodNut) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE TRUSS ROD NUT HAS CHANGED FROM<br />$this->old_trussRodNut<br />
				TO:<br />$this->new_trussRodNut</span><br />";
		}		
		
//  TRUSS WRENCH  //
       	if ($this->old_trussRodWrench) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE TRUSS WRENCH NUT HAS CHANGED FROM<br />$this->old_trussRodWrench<br />
				TO:<br />$this->new_trussRodWrench</span><br />";
		}

//  TUNING MACHINES  //
       	if ($this->old_tuningMachines) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE TUNING MACHINES HAVE CHANGED FROM<br />$this->old_tuningMachines<br />
				TO:<br />$this->new_tuningMachines</span><br />";
		}		
				
//  CATALOG TEXT  //
       	if ($this->old_catalogText) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE CATALOG TEXT HAS CHANGED FROM<br />$this->old_catalogText<br />
				TO:<br />$this->new_catalogText</span><br />";
		}

//  ADDITIONAL COMMENTS  //
       	if ($this->old_additonalComments) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE ADDITIONAL COMMENTS HAVE CHANGED FROM<br />$this->old_additonalComments<br />
				TO:<br />$this->new_additonalComments</span><br />";
		}

//  FRETBOARD  //
       	if ($this->old_fretboard) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE FRETBOARD HAS CHANGED FROM<br />$this->old_fretboard<br />
				TO:<br />$this->new_fretboard</span><br />";
		}

//  HARDWARE  //
       	if ($this->old_hardware) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE HARDWARE HAS CHANGED FROM<br />$this->old_hardware<br />
				TO:<br />$this->new_hardware</span><br />";
		}

//  MIDDLE PICKUP  //
       	if ($this->old_middlePickup) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE MIDDLE PICKUP HAS CHANGED FROM<br />$this->old_middlePickup<br />
				TO:<br />$this->new_middlePickup</span><br />";
		}

//  NECK PICKUP  //
       	if ($this->old_neckPickup) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">THE NECK PICKUP HAS CHANGED FROM<br />$this->old_neckPickup<br />
				TO:<br />$this->new_neckPickup</span><br />";
		}


// IF NO CHANGES NOTHING WAS ADDED TO THE MESSAGE STRING
		if ($msg == $this->prodNo)
		{
			echo "<fieldset>";
            $msg .= "<br/><span class=\"bold\">NO CHANGES MADE<br /> </span><h4>$this->new_prodName</h4><br /></fieldset>";
        }
       	 	return $msg;
			
	}  //  END GET CHANGE MESSAGE  //

}  //  END CHANGES  //













$changelog = array();						
 						
 
/////////////////////////////////////////////////////////  FINE BELOW THE LINE  /////////////////////////////////////
 include('/cs_sku_parse_connect.php');

// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );

// GET THE XML FEED IN A STRING
$xml = file_get_contents($url);
 
// MAKE AN OBJECT OUT OF THE XML
$obj = SimpleXML_Load_String($xml);

foreach ($obj->model as $model)
{  //  FOR EACH
	$new_brand = (string)$model->brand;
	$new_bridge = (string)$model->bridge;
	$new_bridgePickup = (string)$model->bridgePickup;
	$new_buyCodeUSA = (string)$model->buyCodeUSA;
	$new_prodColor = (string)$model->prod_color;
	$new_prodDisplayName = (string)$model->prod_displayName;
	$new_prodMsrp = (string)$model->prod_msrp;
	$new_prod_part_number = (string)$model->prod_part_number;
	$new_prod_upc = (string)$model->prod_upc;
	$new_casegigbag = (string)$model->case_gig_bag;
	$new_controlKnobs = (string)$model->controlKnobs;
	$new_controls = (string)$model->controls;
	$new_fingerBoardRadius = (string)$model->fingerBoardRadius;
	$new_fretSize = (string)$model->fretSize;
	$new_headstock = (string)$model->headstock;
	$new_height = (string)$model->height;
	$new_id = (string)$model->id;
	$new_includedAccessories = (string)$model->includedAccessories;
	$new_legalese = (string)$model->legalese;
	$new_length = (string)$model->length;
	$new_bodyShape = (string)$model->bodyShape;
	$new_neckMaterial = (string)$model->neckMaterial;
	$new_neckPlate = (string)$model->neckPlate;
	$new_neckShape = (string)$model->neckShape;
	$new_numFrets = (string)$model->numFrets;
	$new_nutWidth = (string)$model->nutWidth;
	$new_originCountry = (string)$model->originCountry;
	$new_picks = (string)$model->picks;
	$new_pickupConfiguration = (string)$model->pickupConfiguration;
	$new_pickupSwitching = (string)$model->pickupSwitching;
	$new_polishingCloth = (string)$model->polishingCloth;
	$new_positionInlays = (string)$model->positionInlays;
	$new_prodId = (string)$model->prodId;
	$new_prodSubType = (string)$model->prodSubType;
	$new_prodType = (string)$model->prodType;
	$new_prod_brand = (string)$model->prod_brand;
	$new_prodLongDesc = (string)$model->prodLongDesc;
	$new_prodType = (string)$model->prodType;
	$new_prodName = (string)$model->prodName;
	$prodNo = (string)$model->prodNo;
	$new_series = (string)$model->series;
	$new_subBrand = (string)$model->subBrand;
	$new_productDisplayRank = (string)$model->productDisplayRank;
	$new_productLine = (string)$model->productLine;
	$new_adjWrench = (string)$model->sadHgtAdjWrench;
	$new_scaleLength = (string)$model->scaleLength;
	$new_series = (string)$model->series;
	$new_seriesDisplayRank = (string)$model->seriesDisplayRank;
	$new_strapButtons = (string)$model->strapButtons;
	$new_stringNut = (string)$model->stringNut;
	$new_strings = (string)$model->strings;
	$new_subBrndDisRank = (string)$model->subBrandDisplayRank;
	$new_switchTip = (string)$model->switchTip;
	$new_tremoloArmHandle = (string)$model->tremoloArmHandle;
	$new_trussRodNut = (string)$model->trussRodNut;
	$new_trussRodWrench = (string)$model->trussRodWrench;
	$new_tuningMachines = (string)$model->tuningMachines;
	$new_uniqueFeatures = (string)$model->uniqueFeatures;
	$new_volume = (string)$model->volume;
	$new_isConDisp = (string)$model->isConDisp;
	$new_catalogText = (string)$model->catalogText;
	$new_additonalComments = (string)$model->additonalComments;
	$new_fretboard = (string)$model->fretboard;
	$new_hardware = (string)$model->hardware;
	$new_middlePickup = (string)$model->middlePickup;
	$new_neckPickup = (string)$model->neckPickup;
	



		

	
//  END OF PARSE AND PREP


	
 if ($new_brand=='Fender' && $new_prodSubType=='Electric Guitars' && $new_prodType=='Guitars') { 
 
		
// SELECT THE ROW FROM THE TABLE AND GET THE OLD INFORMATION INTO LOCAL VARIABLES
   		$q = "SELECT field_id_29, field_id_30, field_id_31, field_id_32, field_id_33, field_id_34, field_id_35, field_id_36, field_id_37, field_id_38, field_id_39, field_id_40, field_id_41, field_id_42, field_id_43, field_id_44, field_id_45, field_id_46, field_id_48, field_id_49, field_id_53, field_id_85, field_id_86, field_id_87, field_id_88, field_id_89, field_id_90, field_id_91, field_id_92, field_id_93, field_id_94, field_id_95, field_id_96, field_id_97, field_id_98, field_id_99, field_id_100, field_id_101, field_id_102, field_id_103, field_id_104, field_id_105, field_id_106, field_id_107, field_id_108, field_id_109, field_id_110, field_id_111, field_id_112, field_id_113, field_id_114, field_id_115, field_id_117, field_id_118, field_id_119, field_id_120, field_id_121, field_id_122, field_id_123, field_id_124, field_id_143, field_id_273, field_id_303, field_id_304, field_id_305, field_id_306, field_id_307 FROM exp_weblog_data WHERE (field_id_104='$prodNo' AND weblog_id ='11') LIMIT 1";
			
    	$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
		$row = mysqli_fetch_assoc($r);
		
		$old_bridge = $row['field_id_29'];
		$old_brand = $row["field_id_30"];
		$old_bridgePickup = $row["field_id_31"];
		$old_buyCodeUSA = $row["field_id_32"];
		$old_prodColor = $row["field_id_33"];
		$old_prodDisplayName = $row['field_id_34'];
		$old_prodMsrp = $row["field_id_35"];
		$old_prod_part_number = $row["field_id_36"];
		$old_prod_upc = $row["field_id_37"];
		$old_casegigbag = $row["field_id_38"];
		$old_controlKnobs = $row["$field_id_39"];
		$old_controls = $row["field_id_40"];
		$old_fingerBoardRadius = $row["field_id_41"];
		$old_fretSize = $row["field_id_42"];
		$old_headstock = $row["field_id_43"];
		$old_height = $row["field_id_44"];
		$old_id = $row["field_id_45"];
		$old_includedAccessories = $row["field_id_46"];
		$old_legalese = $row["field_id_48"];
		$old_length = $row["field_id_49"];
		$old_bodyShape = $row["field_id_53"];
		$old_neckMaterial = $row["field_id_85"];
		$old_neckPlate = $row["field_id_86"];
		$old_neckShape = $row["field_id_87"];
		$old_numFrets = $row["field_id_88"];
		$old_nutWidth = $row["field_id_89"];
		$old_originCountry = $row["field_id_90"];
		$old_picks = $row["field_id_91"];
		$old_pickupConfiguration = $row["field_id_92"];
		$old_pickupSwitching = $row["field_id_93"];
		$old_polishingCloth = $row["field_id_94"];
		$old_positionInlays = $row["field_id_95"];
		$old_prodId = $row["field_id_96"];
		$old_prodSubType = $row["field_id_97"];
		$old_prodType = $row["field_id_98"];
		$old_prod_brand = $row["field_id_99"];
		$old_prodLongDesc = $row["field_id_100"];
		$old_prodType = $row["field_id_102"];
		$old_prodName = $row["field_id_103"];
		$old_prodNo = $row["field_id_104"];
		$old_series = $row["field_id_105"];
		$old_subBrand = $row["field_id_106"];
		$old_productDisplayRank = $row["field_id_107"];
		$old_productLine = $row["field_id_108"];
		$old_adjWrench = $row["field_id_109"];
		$old_scaleLength = $row["field_id_110"];
		$old_series = $row["field_id_111"];
		$old_seriesDisplayRank = $row["field_id_112"];
		$old_strapButtons = $row["field_id_113"];
		$old_stringNut = $row["field_id_114"];
		$old_strings = $row["field_id_115"];
		$old_subBrndDisRank = $row["field_id_117"];
		$old_switchTip = $row["field_id_118"];
		$old_tremoloArmHandle = $row["field_id_119"];
		$old_trussRodNut = $row["field_id_120"];
		$old_trussRodWrench = $row['field_id_121'];
		$old_tuningMachines = $row['field_id_122'];
		$old_uniqueFeatures = $row['field_id_123'];
		$old_volume = $row['field_id_124'];
		$old_hardware = $row['field_id_305'];
		$old_middlePickup = $row['field_id_306'];
		$old_neckPickup = $row['field_id_307'];
	
// INSTANTIATE A NEW OBJECT TO LOG THE CHANGES  //

    	$c = new Changes($prodNo);
    		if($new_prodDisplayName!=$old_prodDisplayName)$c->set_prodName($old_prodName, $new_prodName);
			if($new_bridge!=$old_bridge)$c->set_bridge($old_bridge, $new_bridge);
			if($new_bridgePickup!=$old_bridgePickup)$c->set_bridgePickup($old_bridgePickup, $new_bridgePickup);
    		if($new_buyCodeUSA!=$old_buyCodeUSA)$c->set_buyCodeUSA($old_buyCodeUSA, $new_buyCodeUSA);
			if($new_prodColor!=$old_prodColor)$c->set_prodColor($old_prodColor, $new_prodColor);
			if($new_prodDisplayName!=$old_prodDisplayName)$c->set_prodDisplayName($old_prodDisplayName, $new_prodDisplayName);
			if($new_prodmsrp!=$old_prodMsrp)$c->set_prodMsrp($old_prodMsrp, $new_prodMsrp);
			if($new_prod_part_number!=$old_prod_part_number)$c->set_prod_part_number($old_prod_part_number, $new_prod_part_number);
			if($new_prod_upc!=$old_prod_upc)$c->set_prod_upc($old_prod_upc, $new_prod_upc);
			if($new_casegigbag!=$old_casegigbag)$c->set_casegigbag($old_casegigbag, $new_casegigbag);
			if($new_controlKnobs!=$old_controlKnobs)$c->set_controlKnobs($old_controlKnobs, $new_controlKnobs);
			if($new_controls!=$old_controls)$c->set_controls($old_controls, $new_controls);
			if($new_fingerBoardRadius!=$old_fingerBoardRadius)$c->set_fingerBoardRadius($old_fingerBoardRadius, $new_fingerBoardRadius);
			if($new_fretSize!=$old_fretSize)$c->set_fretSize($old_fretSize, $new_fretSize);
			if($new_headstock!=$old_headstock)$c->set_headstock($old_headstock, $new_headstock);
			if($new_height!=$old_height)$c->set_height($old_height, $new_height);
			if($new_id!=$old_id)$c->set_id($old_id, $new_id);
			if($new_includedAccessories!=$old_includedAccessories)$c->set_includedAccessories($old_includedAccessories, $new_includedAccessories);
			if($new_legalese!=$old_legalese)$c->set_legalese($old_legalese, $new_legalese);
			if($new_length!=$old_length)$c->set_length($old_length, $new_length);
			if($new_bodyShape!=$old_bodyShape)$c->set_bodyShape($old_bodyShape, $new_bodyShape);
			if($new_neckMaterial!=$old_neckMaterial)$c->set_neckMaterial($old_neckMaterial, $new_neckMaterial);
			if($new_neckPlate!=$old_neckPlate)$c->set_neckPlate($old_neckPlate, $new_neckPlate);
			if($new_neckShape!=$old_neckShape)$c->set_neckShape($old_neckShape, $new_neckShape);
			if($new_numFrets!=$old_numFrets)$c->set_numFrets($old_numFrets, $new_numFrets);
			if($new_nutWidth!=$old_nutWidth)$c->set_nutWidth($old_nutWidth, $new_nutWidth);
			if($new_originCountry!=$old_originCountry)$c->set_originCountry($old_originCountry, $new_originCountry);
			if($new_picks!=$old_picks)$c->set_picks($old_picks, $new_picks);
			if($new_pickupConfiguration!=$old_pickupConfiguration)$c->set_pickupConfiguration($old_pickupConfiguration, $new_pickupConfiguration);
			
			if($new_picks!=$old_picks)$c->set_picks($old_picks, $new_picks);
			if($new_pickupSwitching!=$old_pickupSwitching)$c->set_pickupSwitching($old_pickupSwitching, $new_pickupSwitching);
			if($new_polishingCloth!=$old_polishingCloth)$c->set_polishingCloth($old_polishingCloth, $new_polishingCloth);
			if($new_positionInlays!=$old_positionInlays)$c->set_positionInlays($old_positionInlays, $new_positionInlays);
			if($new_prodId!=$old_prodId)$c->set_prodId($old_prodId, $new_prodId);
			if($new_prodSubType!=$old_prodSubType)$c->set_prodSubType($old_prodSubType, $new_prodSubType);
			if($new_prodType!=$old_prodType)$c->set_prodType($old_prodType, $new_prodType);
			if($new_prod_brand!=$old_prod_brand)$c->set_prod_brand($old_prod_brand, $new_prod_brand);
			if($new_prodLongDesc!=$old_prodLongDesc)$c->set_prodLongDesc($old_prodLongDesc, $new_prodLongDesc);
			if($new_prodType!=$old_prodType)$c->set_prodType($old_prodType, $new_prodType);
			if($new_prodName!=$old_prodName)$c->set_prodName($old_prodName, $new_prodName);
			if($new_series!=$old_series)$c->set_series($old_series, $new_series);
			if($new_subBrand!=$old_subBrand)$c->set_subBrand($old_subBrand, $new_subBrand);
			if($new_productDisplayRank!=$old_productDisplayRank)$c->set_productDisplayRank($old_productDisplayRank, $new_productDisplayRank);
			
			if($new_productLine!=$old_productLine)$c->set_productLine($old_productLine, $new_productLine);
			//if($new_adjWrench!=$old_adjWrench)$c->set_adjWrench($old_adjWrench, $new_adjWrench);
			if($new_scaleLength!=$old_scaleLength)$c->set_scaleLength($old_scaleLength, $new_scaleLength);
			if($new_seriesDisplayRank!=$old_seriesDisplayRank)$c->set_seriesDisplayRank($old_seriesDisplayRank, $new_seriesDisplayRank);
			
			if($new_strapButtons!=$old_strapButtons)$c->set_strapButtons($old_strapButtons, $new_strapButtons);
			if($new_stringNut!=$old_stringNut)$c->set_stringNut($old_stringNut, $new_stringNut);
			if($new_strings!=$old_strings)$c->set_strings($old_strings, $new_strings);
			if($new_subBrndDisRank!=$old_subBrndDisRank)$c->set_subBrndDisRank($old_subBrndDisRank, $new_subBrndDisRank);
			
			if($new_switchTip!=$old_switchTip)$c->set_switchTip($old_switchTip, $new_switchTip);
			if($new_tremoloArmHandle!=$old_tremoloArmHandle)$c->set_tremoloArmHandle($old_tremoloArmHandle, $new_tremoloArmHandle);
			if($new_trussRodNut!=$old_trussRodNut)$c->set_trussRodNut($old_trussRodNut, $new_trussRodNut);
			if($new_trussRodWrench!=$old_trussRodWrench)$c->set_trussRodWrench($old_trussRodWrench, $new_trussRodWrench);
			if($new_tuningMachines!=$old_tuningMachines)$c->set_tuningMachines($old_tuningMachines, $new_tuningMachines);
			if($new_uniqueFeatures!=$old_uniqueFeatures)$c->set_uniqueFeatures($old_uniqueFeatures, $new_uniqueFeatures);
			if($new_volume!=$old_volume)$c->set_volume($old_volume, $new_volume);
			if($new_isConDisp!=$old_isConDisp)$c->set_isConDisp($old_isConDisp, $new_isConDisp);
			if($new_catalogText!=$old_catalogText)$c->set_catalogText($old_catalogText, $new_catalogText);
			if($new_additonalComments!=$old_additonalComments)$c->set_additonalComments($old_additonalComments, $new_additonalComments);
			if($new_fretboard!=$old_fretboard)$c->set_fretboard($old_fretboard, $new_fretboard);
			if($new_hardware!=$old_hardware)$c->set_hardware($old_hardware, $new_hardware);
			if($new_middlePickup!=$old_middlePickup)$c->set_middlePickup($old_middlePickup, $new_middlePickup);
			if($new_neckPickup!=$old_neckPickup)$c->set_neckPickup($old_neckPickup, $new_neckPickup);
			
			
			
			$changelog[] = $c;



   		$new_bridge = str_replace("'","''",$new_bridge);
		$new_bridgePickup = str_replace("'","''",$new_bridgePickup);
		$new_neckShape = str_replace("'","''",$new_neckShape);
		$new_headstock = str_replace("'","''",$new_headstock);
		$new_prodName = str_replace("'","''",$new_prodName);
		$new_numFrets = str_replace("'","''",$new_numFrets);
		$new_neckShape = str_replace("'","''",$new_neckShape);
		$new_uniqueFeatures = str_replace("'","''",$new_uniqueFeatures);
		$new_prodLongDesc = str_replace("'","''",$new_prodLongDesc);
		$new_prod_brand = str_replace("'","''",$new_prod_brand);
		$new_includedAccessories = str_replace("'","''",$new_includedAccessories);
		$new_prodSubType = str_replace("'","''",$new_prodSubType);
		$new_trussRodNut = str_replace("'","''",$new_trussRodNut);
		$new_tuningMachines = str_replace("'","''",$new_tuningMachines);
		$new_trussRodWrench = str_replace("'","''",$new_trussRodWrench);
		$new_middlePickup = str_replace("'","''",$new_middlePickup);
		$new_neckPickup = str_replace("'","''",$new_neckPickup);
		$q = "UPDATE exp_weblog_data SET field_id_29='$new_bridge', field_id_30='$new_brand', field_id_31='$new_bridgePickup', field_id_32='$new_buyCodeUSA', field_id_33='$new_prodColor', field_id_34='$new_prodDisplayName', field_id_35='$new_prodMsrp', field_id_36='$new_prod_part_number', field_id_37='$new_prod_upc', field_id_38='$new_casegigbag', field_id_39='$new_controlKnobs', field_id_40='$new_controls', field_id_41='$new_fingerBoardRadius', field_id_42='$new_fretSize', field_id_43='$new_headstock', field_id_44='$new_height', field_id_45='$new_id', field_id_46='$new_includedAccessories', field_id_48='$new_legalese', field_id_49='$new_length', field_id_53='$new_bodyShape', field_id_85='$new_neckMaterial', field_id_86='$new_neckPlate', field_id_87='$new_neckShape', field_id_88='$new_numFrets', field_id_89='$new_nutWidth', field_id_90='$new_originCountry', field_id_91='$new_picks', field_id_92='$new_pickupConfiguration', field_id_93='$new_pickupSwitching', field_id_94='$new_polishingCloth', field_id_95='$new_positionInlays', field_id_96='$new_prodId', field_id_97='$new_prodSubType', field_id_98='$new_prodType', field_id_99='$new_prod_brand', field_id_100='$new_prodLongDesc', field_id_102='$new_prodType', field_id_103='$new_prodName', field_id_105='$new_series', field_id_106='$new_subBrand', field_id_107='$new_productDisplayRank', field_id_108='$new_productLine', field_id_109='$new_adjWrench', field_id_110='$new_scaleLength', field_id_111='$new_series', field_id_112='$new_seriesDisplayRank', field_id_113='$new_strapButtons', field_id_114='$new_stringNut', field_id_115='$new_strings', field_id_117='$new_subBrndDisRank', field_id_118='$new_switchTip', field_id_119='$new_tremoloArmHandle', field_id_120='$new_trussRodNut', field_id_121='$new_trussRodWrench', field_id_122='$new_tuningMachines', field_id_123='$new_uniqueFeatures', field_id_124='$new_volume', field_id_143='$new_isConDisp', field_id_273='$new_catalogText',  field_id_303='$new_additonalComments', field_id_304='$new_fretboard', field_id_305='$new_hardware', field_id_306='$new_middlePickup', field_id_307='$new_neckPickup' WHERE field_id_104='$prodNo' LIMIT 1";
    	$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
	//echo $prodNo . "<br /><br />";	    
	
	 }  //  END MAIN IF  //	
	}  //  END MAIN FOREACH  //


// NOW SHOW THE CHANGELOG
foreach ($changelog as $change_object) {
	$msg = $change_object->get_change_message();
	echo "<br /><fieldset>";
    echo "<br /><h4>PRODUCT NUMBER: &nbsp; $msg <br />" . PHP_EOL . "<br /></fieldset><br />";
}
echo "<br /><br /></fieldset>";
?>





</div>
<!--  END WRAPPER  -->
</body>
</html>

Open in new window

0
Comment
Question by:rgranlund
  • 3
4 Comments
 
LVL 6

Expert Comment

by:ramelong
ID: 35162498
You can change the way of verifying the change from
if ($this->old_something) {

Open in new window

to:
if ($this->old_something != $this->new_something) {

Open in new window

With this you can detect changes when $this->old_something is empty.
For instance, see the snippet below...
Try this and let me know how it works.

As an advice: you need to learn how to manage arrays instead of any amount of variables.
// ADD TO THE MESSAGE FOR ANY CHANGES



//  BRAND  //
		if ($this->old_brand != $this->new_brand) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BRAND HAS CHANGED FROM<br />$this->old_brand<br />
				TO:<br />$this->new_brand</span><br />";
		}
		
//  BRIDGE  //
		if ($this->old_bridge != $this->new_bridge) {
			$msg .= "<br /><h4>$this->new_prodName</h4><br /><span class=\"green\">BRIDGE HAS CHANGED FROM<br />$this->old_bridge<br />
				TO:<br />$this->new_bridge</span><br />";
		}

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35164638
Wow, 1300+ lines of code?

PHP has some unique definitions about variables that are NULL, zero, not set, empty, etc.  This is because PHP is a "loosely typed" language - variables assume different data types depending on the context.  That makes life easy for most novice programmers, but also introduces risks when you're making assumptions about external inputs.  Looks like you have found an example of the risk!  Please read the return values here:
http://us2.php.net/manual/en/function.empty.php

See also isset() and the related is_[datatype]() functions documented in the left sidebar of this page:
http://us2.php.net/manual/en/function.isset.php

Your learning process can start by setting error_reporting(E_ALL) so you can check to be sure that you are not accidentally relying on any undefined variables.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35164716
Consider the code snippet.  Loose typing is at work here.  The if() statement will be evaluated as TRUE in the case that $this->old_brand is:
(1) Set to a value, and
(2) the value is not Zero, "0", NULL, FALSE, empty string, empty array, etc.

Your set_error_handler() function is preventing you from getting this understanding because it is suppressing messages that you really need to see at this point in the life cycle.  Get rid of it and use error_reporting(E_ALL) instead.

I may have forgotten to recommend it before, but you might want to get this book.  It is really helpful with great examples.
http://www.sitepoint.com/books/phpmysql4/

Best regards, ~Ray
if ($this->old_brand) 
    {
        $msg .= "xxx";
    }

Open in new window

0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 35164892
Also, line numbers 1107 and 1108 say this:

// GET THE XML FEED IN A STRING
$xml = file_get_contents($url);

According to my code scan, $url is undefined at line 1108.  Perhaps it was defined externally and brought in by the statement on line 1102?  Or perhaps the script is relying on register_globals?  If the latter, you might want to learn why this is deprecated and remove the reliance.
http://php.net/manual/en/security.globals.php

Looking at this in total, I think a complete rewrite is in order.  You would want to determine what data source is the canonical reference for the information you are keeping.  If it were up to me, I would use the names of the columns in my data base table.  You can use a "SHOW COLUMNS" query to get a real-time view.  I would match these names to the names of the fields in $obj->model.  If anything shows up in $obj->model that is not in my column names, it would trigger a notice to me, and I could use ALTER TABLE to add a column in case I wanted to track that information.  I would not let a failure occur over the presence of new information, just a notice.  (If you wanted to be highly sophisticated about it you might let the script "learn the names" by automatically adding columns any time it finds new information in $obj->model, but that is getting ahead of the concept.)

In a design like that, you would have a single generalized setter() and getter() method to access any column.  You would send the column name and the value to be assigned.  This is somewhat like the "active record" design pattern.  It would help you separate the code and logic from the data.  It is the design that often underpins data base driven web sites.

If you want to have a permanent record of the changes to your data model, you probably want to keep a change log. This would simply be a table that contains one row for each incoming XML string.  You would preserve the original state of the data base (as first loaded or as versioned) in a table, and you would keep the changes to the data base in a separate log table.  You could reconstruct the then-current state of the data base at any point in time by simply reapplying the logged changes in the order they were received.  A design strategy like this enables you to answer historical and trend questions.  Cause-and-effect case studies, and data mining become possible in ways that are prevented by your current design.

The strategy of keeping all the data might at first seem wasteful, but consider that you can buy a GB of storage for less than the cost of a roll of toilet paper.  For only a few pennies, you can have a permanent historical record - that seems like a potentially enormous advantage with very little associated cost.

BTW, do not feel bad for a moment about refactoring this application.  As Fred Brooks wrote decades ago, "Plan to throw one away."  When you start building applications for the first time, you will throw the first version away; that is not a error or an indication of failure.  The only error is failing to plan for that fact of life, or worse, keeping the first version when you know that a second version would be better, faster, easier to maintain, etc.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now