Jump to content

jason2

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Posts posted by jason2

  1. Wow! That was a great response, thanks a ton. I get it now.

    Upon further thought, I really do not need the ID column for the "tags" table, do I? All I need is what tag is associated with which entry, and thats enough uniqueness to find which posts have which tags. If I'm missing something, though, let me know.
  2. I want to "tag" some database entries (MySQL) with single word tags, then be able to search for posts that have certain tags. What's the best way to store tags in a database so I can easily search by tag through PHP?

    Right now I insert them into one column, each tag seperated by commas...but I want to be able to search all entries for one specific tag...looking for any pointers on this. Thanks
  3. I'm trying to make a really simple XML parser for my website, but its been a couple years since I've used PHP and so many things are lost in my brain now, lol. Anyway, I'm trying to achieve a simple XML parser object that you can feed it a filename, and it will spit out HTML for the content of that file. However, I'm getting the error:

    [code]Warning: xml_parse(): Unable to call handler start_tag() in C:\Program Files\Apache Group\Apache2\htdocs\parser.php on line 34

    Warning: xml_parse(): Unable to call handler content() in C:\Program Files\Apache Group\Apache2\htdocs\parser.php on line 34

    Warning: xml_parse(): Unable to call handler content() in C:\Program Files\Apache Group\Apache2\htdocs\parser.php on line 34[/code]

    In fact, lots and lots of these errors (I'm guessing corresponding to each element it tries unsuccessfully to parse from the file. The problem is that I'm really sure I got the code right, lol. Here's the PHP code for the object, I don't understand why it can't find the functions when I named them right and all.

    [code]<?php
    /************************
    *  XML parser class
    *************************/

    class XML {
    var $item_array = array();
    var $counter = 0;

    function start_tag($parser, $tag) {
    global $current;
    echo "Start: ".$current;
    }

    function end_tag($parser, $tag) {
        global $current;
        echo "Ended: ".$current;
    }

    function content($parser, $cdata) {
    global $current;
        echo "Content: ".$cdata;
    }


    function XML($xml_file) {
    $parser = xml_parser_create();
    xml_set_element_handler($parser, "start_tag", "end_tag");
    xml_set_character_data_handler($parser, "content");

    $fp = fopen($xml_file, "r") or die("Cannot open ".$xml_file);
    $data = fread($fp, filesize($xml_file)) or die("Could not read file");

    if(!(xml_parse($parser, $data, feof($fp)))) {
    die("Error on line: ".xml_get_current_line_number($parser));
    }

    xml_parser_free($parser);
    fclose($fp);
    }



    }
    ?>[/code]

    Thanks in advance for the help!
×
×
  • 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.