Jump to content

Colton.Wagner

Members
  • Posts

    157
  • Joined

  • Last visited

Everything posted by Colton.Wagner

  1. Nope it didn't work with no errors. I'm telling you I couldn't figure it out.
  2. Yes, products_id categories 1 76 2 76 3 76 4 76 to 17659..
  3. I have 17659 entries that are all the same. There are only two fields in the mysql databse Products_id witch auto increments and categories_id witch is an int 10. This source code throws no errors. <?php error_reporting(E_ALL); $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Connection Error:' . mysql_error()); } mysql_select_db('catgories', $con); $result = mysql_query("SELECT * FROM categories"); $query = "INSERT INTO categories ('products_id', 'categories_id') VALUES ('', '18')"; $i = 1; while ($i <= 17659) { mysql_query($query); $i++; } ?>
  4. I get an xml feed every thirty minutes and im try to take it and match the part numbers then update the quantities here is what I have so far. Can anyone help? <?php session_start(); $_SESSION['parts'] = array(); error_reporting(E_ALL); ?> <html> <head> <link rel="shortcut icon" href="/favicon.ico" /> <title> </title> </head> <body> <?php mysql_connect(""); 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); 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("","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); $quantity = ($_SESSION['parts']['QTY']); $part = ($_SESSION['parts']['PART']); ?> </body> </html> The error is this: Notice: Undefined variable: quantity in on line 31 Notice: Undefined variable: part in on line 31 I'm getting this error because you can't make a variable out of a $_SESSION array.
  5. I see why it isn't working I just don't know how to fix it. I need it to check for those variables after it parses the xml or else it wont work. Is there another way to update the fields via xml parsing?
  6. They are for sure not miss typed they have been defined but they are not being parsed in correctly because I don't know how to correctly process the syntax to do it. The way i have that set up is it parse's the xml into the $_SESSION['parts']['wty'] then it sets that equal to the variable $quanitity then updates that into the database im not so sure that i am using the correct syntax for that.
  7. They are for sure not miss typed they have been defined but they are not being parsed in correctly because I don't know how to correctly process the syntax to do it.
  8. I have made an xml quantity uploading script here it doesnt seem to update the quantity can you tell me what im doing wrong? <?php session_start(); $_SESSION['parts'] = array(); error_reporting(E_ALL); ?> <html> <head> <link rel="shortcut icon" href="/favicon.ico" /> <title> TItle of the website </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("xml filename","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> The error is as follows: Notice: Undefined index: QTY in on line 22 Notice: Undefined index: PART in on line 23 Notice: Undefined variable: quantity in on line 34 Notice: Undefined variable: part in on line 34 Notice: Undefined variable: quantity in on line 34 Notice: Undefined variable: part in on line 34 That goes on for days
  9. 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
  10. It had nothing to do with you it was all my fault. I fixed it by changing the table name. Your a life saver. How do I mark this as solved?
  11. Same ERROR: Notice: MySQL Failed: [iNSERT INTO (`WAREHOUSELOC`,`TRACKINGNUMBER`,`PARTNUMBER`,`NAME`,`IMAGENAME`,`PRIMARYCATALOG`,`PRIMARYYEAR`,`PRIMARYPAGE`,`ORIGINCOUNTRY`,`PRICE`,`DESCRIPTION`) VALUES ('0-00-00-00','152130','DU1277','DRAGON PROP','/oscommerce/catalog/images/DU1277.jpg','MAIN CATALOG','2006','Page 12','USA','3450.00','This beautiful piece stands approximately 8 feet tall. Foam filled latex with metal base. Ships via truck only')]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`WAREHOUSELOC`,`TRACKINGNUMBER`,`PARTNUMBER`,`NAME`,`IMAGENAME`,`PRIMARYCATALOG' at line 1 in on line 54
  12. Seems like I will be able to figure it out but here is what it pulled right away. Notice: MySQL Failed: [iNSERT INTO values (`WAREHOUSELOC`,`TRACKINGNUMBER`,`PARTNUMBER`,`NAME`,`IMAGENAME`,`PRIMARYCATALOG`,`PRIMARYYEAR`,`PRIMARYPAGE`,`ORIGINCOUNTRY`,`PRICE`,`DESCRIPTION`) VALUES ('0-00-00-00','152130','DU1277','DRAGON PROP','/oscommerce/catalog/images/DU1277.jpg','MAIN CATALOG','2006','Page 12','USA','3450.00','This beautiful piece stands approximately 8 feet tall. Foam filled latex with metal base. Ships via truck only')]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values (`WAREHOUSELOC`,`TRACKINGNUMBER`,`PARTNUMBER`,`NAME`,`IMAGENAME`,`PRIMARY' at line 1 in on line 54
  13. yes, I do it is a huge file so good luck. http://nicknackery.com/un-released/xml.xml
  14. After using all of your corrections it still pulled up the same error. Thank you however for cleaning up my code.
  15. alright I took it out. Here is the problem hopefully I can explain it better. The xml file has 20 different fractions. Now not all of them are entered into the file. For instance say there was no recorded description for the object it would put this error message out. Notice: Undefined index: DESCRIPTION in on line 53 how do I make it ignore that sometime it wont be there. I already have the database read the ones that cause problems set to null. Any suggestions?
  16. Here is my problem I have a .xml file that is 15mb. I have to import all of the information into the mysql database. Here is the real problem the xml file is not constant how do I make it continue to insert the values even if some of them are empty? <?php session_start(); $_SESSION['parts'] = array(); ?> <html> <head> <link rel="shortcut icon" href="/favicon.ico" /> <title> title </title> </head> <body> <?php mysql_connect('', '', ''); mysql_select_db('products'); $parser = xml_parser_create(); function start($parser, $element_name, $element_attrs) { switch($element_name) { case "WAREHOUSELOC": // this is the start of a set of data $_SESSION['parts'] = array(); // create an empty set break; case "DESCRIPTION": $query = sprintf("INSERT INTO values (warehouseloc, trackingnumber, partnumber, name, imagename, primarycatalog primaryyear, primarypage, origincountry, weight, price, catagory1, catagory2, catagory3, catagory4, web_catagory1, web_catagory2, web_catagory3, web_catagory4, description) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',)", mysql_real_escape_string($_SESSION['parts']['WAREHOUSELOC']), mysql_real_escape_string($_SESSION['parts']['TRACKINGNUMBER']), mysql_real_escape_string($_SESSION['parts']['PARTNUMBER']), mysql_real_escape_string($_SESSION['parts']['NAME']), mysql_real_escape_string($_SESSION['parts']['IMAGENAME']), mysql_real_escape_string($_SESSION['parts']['PRIMARYCATALOG']), mysql_real_escape_string($_SESSION['parts']['PRIMARYYEAR']), mysql_real_escape_string($_SESSION['parts']['PRIMARYPAGE']), mysql_real_escape_string($_SESSION['parts']['ORIGINCOUNTRY']), mysql_real_escape_string($_SESSION['parts']['WEIGHT']), mysql_real_escape_string($_SESSION['parts']['PRICE']), mysql_real_escape_string($_SESSION['parts']['CATAGORY1']), mysql_real_escape_string($_SESSION['parts']['CATAGORY2']), mysql_real_escape_string($_SESSION['parts']['CATAGORY3']), mysql_real_escape_string($_SESSION['parts']['CATAGORY4']), mysql_real_escape_string($_SESSION['parts']['WEB_CATAGORY1']), mysql_real_escape_string($_SESSION['parts']['WEB_CATAGORY2']), mysql_real_escape_string($_SESSION['parts']['WEB_CATAGORY3']), mysql_real_escape_string($_SESSION['parts']['WEB_CATAGORY4']), mysql_real_escape_string($_SESSION['parts']['DESCRIPTION'])); mysql_query($query); break; default: } } function stop($parser, $element_name) { } function char($parser,$data) { $data = trim($data); if($data != ''){ if(!isset($_SESSION['parts']['WAREHOUSELOC'])){ $_SESSION['parts']['WAREHOUSELOC'] = $data; } elseif(!isset($_SESSION['parts']['TRACKINGNUMBER'])){ $_SESSION['parts']['TRACKINGNUMBER'] = $data; } elseif (!isset($_SESSION['parts']['PARTNUMBER'])){ $_SESSION['parts']['PARTNUMBER'] = $data; } elseif (!isset($_SESSION['parts']['NAME'])){ $_SESSION['parts']['NAME'] = $data; } elseif (!isset($_SESSION['parts']['IMAGENAME'])){ $_SESSION['parts']['IMAGENAME'] = $data; } elseif (!isset($_SESSION['parts']['PRIMARYCATALOG'])){ $_SESSION['parts']['PRIMARYCATALOG'] = $data; } elseif (!isset($_SESSION['parts']['PRIMARYYEAR'])){ $_SESSION['parts']['PRIMARYYEAR'] = $data; } elseif (!isset($_SESSION['parts']['PRIMARYPAGE'])){ $_SESSION['parts']['PRIMARYPAGE'] = $data; } elseif (!isset($_SESSION['parts']['ORIGINCOUNTRY'])){ $_SESSION['parts']['ORIGINCOUNTRY'] = $data; } elseif (!isset($_SESSION['parts']['WEIGHT'])){ $_SESSION['parts']['WEIGHT'] = $data; } elseif (!isset($_SESSION['parts']['PRICE'])){ $_SESSION['parts']['PRICE'] = $data; } elseif (!isset($_SESSION['parts']['CATAGORY1'])){ $_SESSION['parts']['CATAGORY1'] = $data; } elseif (!isset($_SESSION['parts']['CATAGORY2'])){ $_SESSION['parts']['CATAGORY2'] = $data; } elseif (!isset($_SESSION['parts']['CATAGORY3'])){ $_SESSION['parts']['CATAGORY3'] = $data; } elseif (!isset($_SESSION['parts']['CATAGORY4'])){ $_SESSION['parts']['CATAGORY4'] = $data; } elseif (!isset($_SESSION['parts']['WEB_CATAGORY1'])){ $_SESSION['parts']['WEB_CATAGORY1'] = $data; } elseif (!isset($_SESSION['parts']['WEB_CATAGORY2'])){ $_SESSION['parts']['WEB_CATAGORY2'] = $data; } elseif (!isset($_SESSION['parts']['WEB_CATAGORY3'])){ $_SESSION['parts']['WEB_CATAGORY3'] = $data; } elseif (!isset($_SESSION['parts']['WEB_CATAGORY4'])){ $_SESSION['parts']['WEB_CATAGORY4'] = $data; } elseif (!isset($_SESSION['parts']['DESCRIPTION'])){ $_SESSION['parts']['DESCRIPTION'] = $data; } } } xml_set_element_handler($parser, "start", "stop"); xml_set_character_data_handler($parser, "char"); $fp=fopen("xml.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! I am new to Php programming and this is one of the friendliest community environments I have been in.
  17. The %d was thrown in by accedent that just converts the value to a binary integer. I took it out no errors.
×
×
  • 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.