Jump to content

Archived

This topic is now archived and is closed to further replies.

birdie

php in mysql fetched objects

Recommended Posts

hi, i have a problem with using a database to store php information within html text. I would like to know whether there is an easier way than treating it like bbcode.

Here is one example..

[code]
$sql = "SELECT * FROM table";
$query = mysql_query($sql);
$object = mysql_fetch_object($query);

echo $object->field;

[/code]

Say this field had something like this in it..

[code]
<html><p>Hello my name is <? echo "Birdie"; ?></p></html>
[/code]

Any way of echo'ing the information so that "hello my name is Birdie" is displayed instead of an exact copy of the example above?

Thanks, i've never figured this out before.

Share this post


Link to post
Share on other sites
yes in fact there is 2 easier ways.  You can use php's wide array of file handling functions to create a file and write the html to that file, and read contents from that file when needed.  Like session variables are stored to there own file you can do so with php file handling to store whateveer you want in whatever file type you want, only thing is keep them outside the server, unlessyou don't mind people being able to pull them up just by typing them in the url.

Share this post


Link to post
Share on other sites
You can use eval to execute PHP code within a string. However be extremely careful when using eval. If a cracker finds out you are using eval, he can put in some nasty PHP code, which could pertentialy delete every file for your website/database!!

Share this post


Link to post
Share on other sites
wow, its a good thing php code cannot be inserted into my database then..

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.