SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trying to show data from xml

    Hi guys

    This is the xml feed I am trying to pull data from, at the moment it enters the rows into the database but the rows are blank, why is it entering blank
    ?

    This is my code

    PHP Code:
    <?php

    $file 
    "http://xml.boylesports.com/xml/Golf1.xml";

    function 
    contents($parser$data){


        echo 
    $data;
    }

    function 
    startTag($parser$data){
        echo 
    "<b>";
    }

    function 
    endTag($parser$data){

     
    $feedItem = array();
         
    $feedItem['event'] = $data->event;
         
    $feedItem['bet name'] = $event->bet;

        echo 
    "</b><br />";
    $sql "INSERT INTO Bets
    (bet) 


    VALUES('
    $feeditem')";

    $query mysql_query($sql) or die('Error: ' mysql_error());

    }

    $xml_parser xml_parser_create();

    xml_set_element_handler($xml_parser"startTag""endTag");

    xml_set_character_data_handler($xml_parser"contents");

    $fp fopen($file"r");

    $data fread($fp80000);
     

    if(!(
    xml_parse($xml_parser$datafeof($fp)))){
        die(
    "Error on line " xml_get_current_line_number($xml_parser));
    }

    xml_parser_free($xml_parser);




    fclose($fp);

    ?>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,999
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)
    Please don't cross-post. It makes things difficult trying to follow more than 1 thread. Please see http://www.sitepoint.com/forums/showthread.php?t=573605


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
  •