Colton.Wagner Posted October 20, 2009 Share Posted October 20, 2009 Here is the Code <?php session_start(); $_SESSION['parts'] = array(); error_reporting(E_ALL); ?> <html> <head> <link rel="shortcut icon" href="/favicon.ico" /> <title> NickNackery.com </title> </head> <body> <?php mysql_connect('localhost', 'root', 'roflmao315'); mysql_select_db('products'); $parser = xml_parser_create(); function start($parser, $element_name, $element_attrs) { switch($element_name) { case "SKU": // this is the start of a set of data $_SESSION['parts'] = array(); // create an empty set break; case "TIME": $query = sprintf("UPDATE products SET products_quantity = $quantity WHERE products_model = $part"); mysql_query($query); break; default: } } function stop($parser, $element_name) { } function char($parser,$data) { $data = trim($data); $quantity = trim($quantity); $part = trim($part); if($data != ''){ if(!isset($_SESSION['parts']['SKU'])){ $_SESSION['parts']['SKU'] = $data; } elseif (!isset($_SESSION['parts']['QTY'])){ $_SESSION['parts']['QTY'] = $quantity; } elseif (!isset($_SESSION['parts']['PART'])){ $_SESSION['parts']['PART'] = $part; } } } xml_set_element_handler($parser, "start", "stop"); xml_set_character_data_handler($parser, "char"); $fp=fopen("http://morris.morriscostumes.com/out/available_batchnynyy_001.xml","r"); while ($data=fread($fp,4096)) { xml_parse($parser,$data,feof($fp)) or die (sprintf("XML Error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } xml_parser_free($parser); ?> </body> </html> Here is the error Notice: Undefined variable: quantity in on line 45 Notice: Undefined variable: part in on line 46 Quote Link to comment https://forums.phpfreaks.com/topic/178386-solved-using-xml-parsing-to-update-a-quantity-by-checking/ Share on other sites More sharing options...
taquitosensei Posted October 20, 2009 Share Posted October 20, 2009 $quantity is probably defined outside of that function or not defined at all. You should probably pass quantity to the "char" function along with $parser and $data. Quote Link to comment https://forums.phpfreaks.com/topic/178386-solved-using-xml-parsing-to-update-a-quantity-by-checking/#findComment-940735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.