SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic problems extracting data from PHP feeds

    I say 'basic' because I'm sure this is a simple issue, but I'm just not quite sure where I'm going wrong.

    Anyway, I'm trying to take data out of a feed that is formatted like this:

    Code:
    <progressive_jackpots casino="name">
       <jackpot>
         <game>Data</game>
         <amount>Data</amount>
       </jackpot>
       <jackpot>
         <game>Data</game>
         <amount>Data</amount>
       </jackpot>
    </progressive_jackpots>
    Here's the PHP code I'm using:

    PHP Code:
    $game $progressive_jackpots->jackpot->game;
    $amount $progressive_jackpots->jackpot->amount
    However, I don't seem to be populating either the $game or the $amount variables.

    Can someone point out where I'm going wrong please?

    Thanks a lot

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    What is this: $progressive_jackpots ? An object?
    A little bit more code might be helpful.

  3. #3
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Guido - thanks for the reply.

    Here's the extended piece of the PHP code:

    PHP Code:

    //find parent node for each product
    case 'progressive_jackpots';

    //initialise xml parser
    $dom = new DOMDocument();
    $domNode $xmlReader->expand();
    $element $dom->appendChild($domNode);
    $domString utf8_encode($dom->saveXML($element));
    $product = new SimpleXMLElement($domString);

    //import data
    $game $progressive_jackpots->jackpot->game;
    $amount $progressive_jackpots->jackpot->amount;


    //insert query into database

            
    if ($query mysql_query("REPLACE INTO progressives
            (casino, game, amount)
            
            VALUES ('Go Casino', '
    $game', '$amount')"))
            
            {
            
            }
            
            else
            {
            echo 
    "Problem with <strong>".$name."</strong>: "mysql_error()."<br />";
            }
            
    }



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •