473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

My php script is not picking up the xml info.

290 100+

I am trying to read the lastest clickbank xml file
but I am not picking up the categories properly :(

I am using a simple script to take this data and write it
to a mysql table. The idea is to wite the SITE details only one and if it appears again in the xml then only add the category and sub category info.

The problem:
It looks like my script is not picking up the sub-categories,
but I am not sure how I need to change it.

I think I need another level for the sub-cat ?


This is what I have.


Expand|Select|Wrap|Line Numbers
  1. $xml = simplexml_load_file($file);
  2. $cnt = 0;
  3.  
  4. foreach($xml->Category as $category){
  5.    foreach($category->Site as $site){
  6.  
  7.       $sql_ck = "SELECT cb_id FROM cb_update WHERE id = '$site->Id' AND day_no = '$this_day'";
  8.       $result_ck = mysql_query($sql_ck)
  9.         or die("could not FIND ID in cb_update.". mysql_error());  
  10.  
  11.     $num = mysql_num_rows($result_ck);
  12.  
  13.     if($num == 0) {
  14.         $sql_ins = "INSERT INTO cb_update ( cb_date, day_no, id, title, descrip, recurr, grav, earn, percent, totearn, rebill, refer, comm )
  15.          VALUES ( '$today', '$this_day','$site->Id','$title', '$descrip', '$site->HasRecurringProducts', '$site->Gravity', '$site->EarnedPerSale', '$site->PercentPerSale', '$site->TotalEarningsPerSale', '$site->TotalRebillAmt', '$site->Referred', '$site->Commission' )";
  16.  
  17.          $result_ins = mysql_query($sql_ins) or die("could not execute INSERT to clicky.". mysql_error());  
  18.  
  19.          $sql_ins = "INSERT INTO cb_cat_update (id_cat, cat, pop, day_no_cat)
  20.          VALUES ('$site->Id', '$category->Name', '$site->PopularityRank', '$this_day')";    
  21.  
  22.           $result_ins = mysql_query($sql_ins) or die("could not execute INSERT to cb_cat_update.". mysql_error());        
  23.  
  24.               }
  25.         else {          //  If the SITE has already been written just write the cat and sub-cat
  26.  
  27.           $sql_ins = "INSERT INTO cb_cat_update (id_cat, cat, pop)
  28.          VALUES ('$site->Id', '$category->Name', '$site->PopularityRank')";    
  29.  
  30.          $result_ins = mysql_query($sql_ins) or die("could not execute INSERT to cl_cat.". mysql_error());         
  31.  
  32.          }
  33.      $cnt++;
  34.        }
  35.      }
  36.  
This is the start of the xml file:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE Catalog SYSTEM "marketplace_feed_v1.dtd">
  3. <Catalog>
  4.   <Category>
  5.      <Name>Business to Business</Name>
  6.      <Site>
  7.         * SITE INFO TAGS
  8.       </Site>
  9.       <Category>
  10.          <Name>Education</Name>
  11.          <Site>
  12.          </Category>
  13.          <Category>
  14.          <Name>Publishing</Name>
  15.          <Site>
  16.             * SITE INFO TAGS
  17.          </Site>
  18.        </Category>
  19.   </Category>
  20.   <Category>
  21.      <Name>Society &amp; Culture</Name>
  22.      <Site>
  23.  
As you can see, the "Category" Tag is used twice,
once for the main category andalso for the sub-category

A bit confusing.

I have updated my table to include the sub-category:
INSERT INTO cb_cat_update (id_cat, cat, sub-cat, pop, day_no_cat)

Would appreciate any help so that I can extract the
category AND sub category.

Thanks.
Jan 16 '10 #1
0 1189

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Maxim Vexler | last post by:
Hello to everyone, Assuming i have this simple script : <?PHP //Opening tag =' $html_header=' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
0
by: Burton Roberts | last post by:
I'm using XP Professional on a Dell Inspiron 8100 with 512K Ram. Since April 1 I have been struggling with problems associated with the Script Host . I suspect I let in a virus that Norton...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
2
by: Henry Hollenberg | last post by:
Hello, I have written a script that uses environment variables set during a particular users login in ".bash_profile" and ".profile". I have changed to that users uid and gid in my python...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
9
by: newbiegalore | last post by:
Hello everyone :-) , Thanks to the gentle people on this group for helping me out with previous issues. :-D This time round I am facing what I perceive as a simple problem, which I have not found...
11
by: moltendorf | last post by:
Hey everyone, as I have been by far pleased with some of the top helpers on this forum, I have decided to send another one your way. Even though I am personally having minimal issues with this...
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
3
by: jeddiki | last post by:
Hi, I am using this script which is nearly working correctly, but not quite! When a user selects some text from the web-page and copies it, the script is supposed to pick up the current...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.