Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-19-2009, 06:13 AM
PM User |
#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?
03-19-2009, 08:04 AM
PM User |
#2
Supreme Master coder!
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 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.
03-19-2009, 05:32 PM
PM User |
#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 ..
03-19-2009, 05:42 PM
PM User |
#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)
?>
03-19-2009, 06:34 PM
PM User |
#5
Super Moderator
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 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.
03-19-2009, 10:44 PM
PM User |
#6
Supreme Master coder!
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Quote:
Originally Posted by
guelphdad
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.
03-20-2009, 02:46 AM
PM User |
#7
Super Moderator
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
Quote:
Originally Posted by
Old Pedant
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.
Jump To Top of Thread
Thread Tools
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
HTML code is Off
All times are GMT +1. The time now is 11:20 PM .
Advertisement
Log in to turn off these ads.