Page 1 of 1

Retrieving HTML code stored in a database.

Posted: Wed Apr 02, 2003 1:50 pm
by john_crawford32
HI All,
I have a database with 2 tables.
1 stores html code in a blob that might include text images calls etc.
the other table stores either text or an image call "<img src="images/ads/applehunts.jpg">
in a varchar field.

The blob works fine.
If I store text in the varchar field it is fine but if I store
<img src="images/ads/applehunts.jpg"> in the varchar field I get nothing with this code

Code: Select all

echo $row&#1111;"Info"];
if I use this code

Code: Select all

$mystring = htmlspecialchars($row&#1111;"Info"]);
echo $mystring;
I get
<img src="images/ads/applehunts.jpg">
but no image.
Do I have to use a blob to store html code?
or am I doing something wrong?
Can I change the field type without loosing data?
Thanks
John

Posted: Wed Apr 02, 2003 1:54 pm
by twigletmac
What do you get in the source of the page when you just do:

Code: Select all

echo $row["Info"];
Mac

Posted: Wed Apr 02, 2003 2:23 pm
by HITMAN1net
You would expect what you got for your second attempt though.

The first one should work really. I'm going to end up repeating what john_crawford32 said so I'll just stop there. More info?

---
Ben

Posted: Wed Apr 02, 2003 2:49 pm
by john_crawford32
Here is what I get with

Code: Select all

echo $row&#1111;"Info"];

Code: Select all

<tr><td><HR><BR><BR><BR><BR><a href=' mailto:applebucks@superpa.net' target='blank'>visit their website</a></td></tr>
This is what I get with htmlspecialchars

Code: Select all

<tr><td><HR><BR><BR><BR><img src="images/ads/applehunts.jpg"><BR><a href=' mailto:applebucks@superpa.net' target='blank'>visit their website</a></td></tr>r>
It is strange because there is no error no space just blank.

Posted: Wed Apr 02, 2003 3:45 pm
by Gen-ik
You can can use normal TEXT field in the database, keep your HTML in there, and then to include it in a webpage you simply grab it from the database (I'm sure you know how) and then get it into the page using this..

Code: Select all

<?php
echo(stripslashes($row[html]));
?>
..for example.

It's something I've been using recently and it seems to work fine.

Strange but True

Posted: Thu Apr 03, 2003 9:51 pm
by john_crawford32
I don't understand.
I was experimenting and noticed if I put the photo in a different directory it worked. So I deleted the directory and readded it.
Still didn't work.
then I changed the directory name from ads to dds and it works fine.
What confuses me is that the code doesn't show up.
is "ads" a php function?