The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: Php & Xml

  1. #1

    Php & Xml

    shortened the 1st post since this thread was getting long...

  2. #2
    uncomment this line
    PHP Code:
    //header("Content-type: text/xml"); 
    should be like this:

    PHP Code:
    header("Content-type: text/xml"); 
    I wrote this tutorial about it: http://www.kirupa.com/web/mysql_xml_php.htm

  3. #3
    thanks.. that helped.... forgot I commented it out when trying to debug.....but got another problem.... now

    see below edit post so thread would be shorter and not to much CODE

  4. #4
    that seems like something to do with your database set-up... can't realy tell you how to fix that because all databases are different...

  5. #5
    I thought that but have played around with the DB and still same result ... DB is MYSQL and the table looks like this

    #
    # Table structure for table `board`
    #

    CREATE TABLE board (
    id int(11) NOT NULL auto_increment,
    parent int(11) default '0',
    thread int(11) default '0',
    name tinytext,
    email tinytext,
    subject tinytext,
    message text,
    date timestamp(14) NOT NULL,
    ip varchar(15) default NULL,
    PRIMARY KEY (id)
    ) TYPE=MyISAM;

    i think it has something to do with my array... not sure thought... back to hunting and pecking thru the code....

  6. #6
    heres the next stuck point .....

    NOT.... finally got it figured out.........

    thanks for all the help.......

    working code

    PHP Code:
    <?php
    //{}_______________________________________________________________________________________________________________
        
    $mbname "Message Board";
        
    $dbname "mx_board";
        
    $dbhost "localhost";
        
    $dbuser "root";
        
    $dbpass "";
        
    $limit  "40";
        
    $page 1;
    //{}_______________________________________________________________________________________________________________    
        
    header("Content-type: text/xml");
    //{}_______________________________________________________________________________________________________________    
        
    $link mysql_connect($dbhost$dbuser$dbpass) or die("Error!");
        
    mysql_select_db($dbname$link) or die("Error!");
        
    $q mysql_query("SELECT id FROM board WHERE parent=0 ORDER BY date DESC",$link);
        
    $z mysql_query("SELECT *,UNIX_TIMESTAMP(date) FROM board WHERE parent=0",$link);
        list(
    $id,$parent,$thread,$name,$email,$subject,$message,$baddate,$ip,$date)=mysql_fetch_row($z);
        
    $date date("Y-m-d g:i:sa",$date); 
        
    $list = array();
        while(list(
    $id)=mysql_fetch_row($q)) {
            
    array_push($list,$id);
        }
        
    $num_threads count($list);
        
    $threads array_splice($list,0,($limit $page));
        
    $html .=  "<OBJ who=\"BINARYCORTEX \">FMX BOARD\n";
        foreach(
    $threads as $id) {
                if(
    $id == $thread) {
            
    $html .= "</OBJ>";
        }

            
    thread($id);
        }
        
    $html .= "</OBJ></OBJ>";
        
    mysql_close($link);
        
    swapHtml($html);
    function 
    thread ($id) {
        global 
    $mes_id;
        global 
    $link;
        global 
    $html;
        global 
    $page;
        
    $q mysql_query("SELECT *,UNIX_TIMESTAMP(date) FROM board WHERE id=$id",$link);
        list(
    $id,$parent,$thread,$name,$email,$subject,$message,$baddate,$ip,$date)=mysql_fetch_row($q);
        
    $date date("Y-m-d g:i:sa",$date); 
        
    $name htmlspecialchars($name);
        
    $email htmlspecialchars($email);
        
    $subject htmlspecialchars($subject);
        
    $message htmlspecialchars($message);
        if(
    $id == $thread) {
            
    $html .= "<OBJ who=\"$name\" when=\"$date\" z=\"$id\"  y=\"$parent\"  x=\"$thread\"> $subject";
        }
        if(
    $parent 0) {
            
    $html .= "<OBJ who=\"$name\" when=\"$date\" z=\"$id\" y=\"$parent\"  x=\"$thread\"> $subject";
        }
        
    $q mysql_query("SELECT id FROM board WHERE parent=$id ORDER BY date DESC",$link);
        
    $num=mysql_numrows($q);
        if(
    $num) {
            while(list(
    $id)=mysql_fetch_row($q)){
                
    thread($id);
            }
        }
        if(
    $parent 0) {
            
    $html .= "</OBJ>";
        }
            if(
    $id == $thread) {
            
    $html .= "</OBJ>";
        }
    }
    function 
    swapHtml($html) {
        
    $contents $html;
        echo 
    $contents;
    }
    ?>

  7. #7
    well I thought it was working..... only works for the data I was testing with.. once i tried new data it was broke again...... the code shouldn't be that hard, just trying make a old school message board but in a XML format

    trying to get this
    -1st post
    -----reply to 1st post
    -2nd post
    -3rd post
    ------reply to 3rd
    ------------reply to 2nd of 3rd post
    -4th post

    to look like this in PHP
    <obj>1st post
    <obj>reply to 1st</obj>
    </obj>
    <obj>2nd post</obj>
    <obj>3rd post
    <obj>reply to 3rd
    <obj>reply to 2nd of 3rd post</obj>
    </obj>
    </obj>
    <obj>4th post</ob>

    the above code is somewhat working, having problems inserting the </obj> at the right places....something with the IF statements I think..... please help

    if it helps heres the data in the SQL Database

    CREATE TABLE beta_board (
    id int(11) NOT NULL auto_increment,
    parent int(11) default '0',
    thread int(11) default '0',
    subject tinytext,
    PRIMARY KEY (id)
    ) TYPE=MyISAM;

    #
    # Dumping data for table `beta_board`
    #

    INSERT INTO beta_board VALUES (1, 0, 1, '1ST POST');
    INSERT INTO beta_board VALUES (2, 0, 2, '2ND POST');
    INSERT INTO beta_board VALUES (3, 0, 2, '3RD POST');
    INSERT INTO beta_board VALUES (4, 0, 2, '4TH POST');
    INSERT INTO beta_board VALUES (5, 1, 1, 'REPLY TO 1ST POST');
    INSERT INTO beta_board VALUES (6, 3, 2, 'REPLY TO 3RD POST');
    INSERT INTO beta_board VALUES (7, 6, 2, 'REPLY TO 2ND OF 3RD POST');


    and for anyone who can help me get this working... I'll give the FLA for this project......

    view the project here ----> http://66.93.244.18/dev/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012