Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How do I Parse the HTML?

    I think 'parse' is the term used that means 'make happen' but I'm not sure if parsing the HTML is what I want to do.

    I have a system where you can submit a news post and have it go into a database. There is a page called 'submitnews.html' - this is the page with the form to put in the information. When the information is put in and 'Submit' is hit this page comes into action:

    PHP Code:
    <?php
    ob_start
    ();
    session_start();
    if(!
    session_is_registered(myusername)){
    header("location:stafflogin.html");
    }
    $path './';
    include(
    $path 'above.inc'); ?>

    <title>Website - Submit News</title>

    <?php include($path 'below.inc'); ?>
                
    <div id="main">            
    <h1>Error</h1>                

    <?php 
    $dbhost 
    'host';
    $dbuser 'username';
    $dbpass 'password';
    $conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to mysql');
    $dbname 'database';
    mysql_select_db($dbname); 

    $title $_POST['title'];
    $category $_POST['category'];
    $story $_POST['story'];
    $healthy = array("<"">""\"""\'""&");
    $yummy   = array("&lt;""&gt;""&quot;""'""&amp;");
    $dem str_replace($healthy$yummy$story);
    $itemdescription "$dem";
    $date $_POST['date'];

    $id mysql_real_escape_string((int)$_GET['id']);
    $query "SELECT `id`
    FROM `tablename` 
    ORDER BY `id` DESC 
    LIMIT 0 , 1"
    ;
    $result mysql_query($query);
    $row mysql_fetch_array($result);

    $blabla "SELECT `id`
    FROM `tablename` 
    ORDER BY `id` DESC 
    LIMIT 0 , 1"
    ;
    $mesult mysql_query($blabla);
    $wow mysql_fetch_array($mesult);

    $sql "insert into anothertable (title, category, story, date, permalink, itemlink, itemdescription, author) values ('$title', '$category', '$story', '$date', '<a href=\"/news.html?id={$wow['id']}\">Permalink</a>', 'http://www.halonirvana.com/news.html?id={$row['id']}', '$itemdescription', 'Hyp3r Grunt')"
    $result mysql_query($sql$conn) or die(mysql_error());

    $magic "INSERT INTO tablename (id) VALUES ('')";
    $result mysql_query($magic$conn) or die(mysql_error()); ?>       

    <?php mysql_close($conn);
    header("location:submitnews.html");
    ob_end_flush();
    ?>

    </div>    

    <?php include($path 'furtherbelowalternate.inc'); ?>
    The problem is that the item description variable is then picked up in an RSS 2 feed. It has all the html code still in it, how do I make the html 'happen'.

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I'm not exactly sure what you wanted, but try this and see if it acheives what you want.

    Change

    PHP Code:
    $itemdescription "$dem"
    to

    PHP Code:
    $itemdescription addslashes($story); 

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I got it working, I did what you told me to in a way and I also used 'htmlspecialchars'. Everything is good now, thanks for your help.


  •  

    Posting Permissions

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