...

View Full Version : Pulling html from mysql



amars1983
03-19-2009, 06:13 AM
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?

Old Pedant
03-19-2009, 08:04 AM
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.

amars1983
03-19-2009, 05:32 PM
I was able to look in the database and the html was there.

amars1983
03-19-2009, 05:42 PM
What is a good tool that isn't web based. I've been using phpMyAdmin. Here's my code for reading the records:



<?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)
?>

guelphdad
03-19-2009, 06:34 PM
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.

Old Pedant
03-19-2009, 10:44 PM
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???


...
$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.

guelphdad
03-20-2009, 02:46 AM
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.

oesxyl
03-20-2009, 09:19 AM
I was able to look in the database and the html was there.
try:
http://www.php.net/manual/en/function.htmlspecialchars.php
http://www.php.net/manual/en/function.htmlspecialchars-decode.php

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum