Jump to content

[SOLVED] $_session array update into a server.


Colton.Wagner

Recommended Posts

Here is my problem i am trying to update the quanity of an item every 5 minutes by checking the part number then adding it here is what i have so far.

 

<?php
session_start(); 
$_SESSION['parts'] = array();
error_reporting(E_ALL);
?>
<html>
   <head>
      <link rel="shortcut icon" href="/favicon.ico" />
      <title>
      TItle =p
      </title>
   </head>
   
	<body>
<?php

mysql_connect('', '', '');
mysql_select_db('products');

$parser = xml_parser_create();

$quantity = ($_SESSION['parts']['QTY']);
$part = ($_SESSION['parts']['PART']);

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);
   if($data != ''){
      if(!isset($_SESSION['parts']['SKU'])){
         $_SESSION['parts']['SKU'] = $data;
      } elseif (!isset($_SESSION['parts']['QTY'])){
         $_SESSION['parts']['QTY'] = $data;
      } elseif (!isset($_SESSION['parts']['PART'])){
         $_SESSION['parts']['PART'] = $data;
      }
   }
}

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>

 

Thanks in advanced for the help =p

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.