Jump to content


Photo

php in mysql fetched objects


  • Please log in to reply
4 replies to this topic

#1 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 10 August 2006 - 06:29 PM

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

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

echo $object->field; 


Say this field had something like this in it..

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

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.

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 10 August 2006 - 06:31 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 10 August 2006 - 06:33 PM

ok thanks, i'll try that :)

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 August 2006 - 06:41 PM

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!!

#5 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 10 August 2006 - 10:08 PM

wow, its a good thing php code cannot be inserted into my database then..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users