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 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    22
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Pulling html from mysql

    I'm using tinymce to build a blog for a personal site. I have everything working correctly as far as getting everything into the mysql db, but when pulling all the code from it, it seems to not see it as html code. I inserted just regular text into a field just to make sure my call to the database was working correctly, which it was, but it won't seem to work with the html. Any thoughts?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Use MySQL tools--not any web based tools--to view the data and see if your HTML is there. I will be it it and the problem is in the code that reads the records. But check it out.

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    22
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I was able to look in the database and the html was there.
    Last edited by amars1983; 03-19-2009 at 05:43 PM.

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    22
    Thanks
    3
    Thanked 0 Times in 0 Posts
    What is a good tool that isn't web based. I've been using phpMyAdmin. Here's my code for reading the records:

    Code:
    <?php
    $con = mysql_connect("xxx","xxx","xxxxx");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("xxx", $con);
    
    $blogentry = sprintf("SELECT 'Time', 'Content'
    FROM Blog
    ORDER BY 'Time' DESC");
    $exeentry = mysql_query($blogentry, $con) or die(mysql_error());
    $rowentry = mysql_fetch_assoc($exeentry);
    $totalentry = mysql_num_rows($exeentry);?>
    
    
    <?php if ($totalentry > 0) {do { ?>
    <br /><p>
    <?php echo $rowentry['Content']; ?><br />
    <?php echo $rowentry['Time']; ?> </p>
    <?php } while ($rowentry = mysql_fetch_assoc($exeentry));
    }?>
    <?php mysql_close($con)
    ?>

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Your problem is your php code. You do the call to: mysql_fetch_assoc but then don't print anything out after that, you have your echo statements prior to fetching the data.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Quote Originally Posted by guelphdad View Post
    Your problem is your php code. You do the call to: mysql_fetch_assoc but then don't print anything out after that, you have your echo statements prior to fetching the data.
    Ummm...huh???
    Code:
    ...
    $rowentry = mysql_fetch_assoc($exeentry);
    $totalentry = mysql_num_rows($exeentry);?>
    
    
    <?php if ($totalentry > 0) {do { ?>
    <br /><p>
    <?php echo $rowentry['Content']; ?><br />
    <?php echo $rowentry['Time']; ?> </p>
    <?php } while ($rowentry = mysql_fetch_assoc($exeentry));
    }?>
    Granted, that seems a bit clumsy way to write the code, but it sure looks to me like fetch_assoc is called before each display of the data.

  • #7
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Quote Originally Posted by Old Pedant View Post
    Granted, that seems a bit clumsy way to write the code, but it sure looks to me like fetch_assoc is called before each display of the data.
    Agreed, I missed it being a DO WHILE and not just a WHILE with the DO not broken out to it's own line. But yeah very sloppy if you ask me.

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by amars1983 View Post
    I was able to look in the database and the html was there.
    try:
    http://www.php.net/manual/en/functio...ecialchars.php
    http://www.php.net/manual/en/functio...ars-decode.php

    best regards


  •  

    Posting Permissions

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