Storing PHP Variable in SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oewMind
Forum Newbie
Posts: 3
Joined: Fri Sep 01, 2006 7:36 am

Storing PHP Variable in SQL

Post by oewMind »

I am trying to store a standardized text into a database. I want it to store some of my php session variables so when I call it , it will display the current value.

I am storing text that looks like this:

'<?php echo $firstName; ?> Wants to send you a gift ....'

I tried storing it a couple other ways thinking I had my tags in the wrong place. Stored like that I dont even see the code, I only see 'Wants to send you a gift ...'. So I am thinking its recognizing it but dont know why it isnt printing.

I am putting it my document like this:

echo $row_gift['Description'];

I am thinking I should be trying it in an include and it might work better. So I thought echoing it in another document and trying to include it would work, but didnt.

Help please...

Thanks in advance.
Last edited by oewMind on Fri Sep 01, 2006 10:12 am, edited 1 time in total.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

why not just use something like

Code: Select all

{username} is trying to send you a gift
and then do:

Code: Select all

$newString = str_replace ("{username}", $yourText, $sqlResult);
Much easier to manage in my opinion
oewMind
Forum Newbie
Posts: 3
Joined: Fri Sep 01, 2006 7:36 am

Post by oewMind »

I want to give the owner of the site the ability to add future text selections or edit the current ones. So I would like to pull it from a database rather than hard coded.

Any suggestions?
Post Reply