Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-19-2009, 06:13 AM   PM User | #1
amars1983
New Coder

 
Join Date: Mar 2009
Posts: 22
Thanks: 3
Thanked 0 Times in 0 Posts
amars1983 is an unknown quantity at this point
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?
amars1983 is offline   Reply With Quote
Old 03-19-2009, 08:04 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Old 03-19-2009, 05:32 PM   PM User | #3
amars1983
New Coder

 
Join Date: Mar 2009
Posts: 22
Thanks: 3
Thanked 0 Times in 0 Posts
amars1983 is an unknown quantity at this point
I was able to look in the database and the html was there.

Last edited by amars1983; 03-19-2009 at 05:43 PM..
amars1983 is offline   Reply With Quote
Old 03-19-2009, 05:42 PM   PM User | #4
amars1983
New Coder

 
Join Date: Mar 2009
Posts: 22
Thanks: 3
Thanked 0 Times in 0 Posts
amars1983 is an unknown quantity at this point
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)
?>
amars1983 is offline   Reply With Quote
Old 03-19-2009, 06:34 PM   PM User | #5
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 03-19-2009, 10:44 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Old 03-20-2009, 02:46 AM   PM User | #7
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 03-20-2009, 09:19 AM   PM User | #8
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:20 PM.


Advertisement
Log in to turn off these ads.