Depends the use. If you insert into db and immediatly want to print it then do so. If you store it in db, go to another page then pull it out of the db. If it's in a function then globalize it. If in it's in if statement make sure the condition holds true. If ... In otherwords, show us how you're doing it as there is an infinite number of possibilities.
Desired is : Code from insertion into db to where you're wanting to print it and all in between.
Without that desire being met, nobody can help. Does this make sense now?