Embed Variable Inside LongText data
Is it possible to embed variable in longtext data field?
For instance:
the field name is "description" and it contains...
The date is $date_var.
In PHP/MySQL Query:
$date_var = date('m/d/Y');
echo $row['description'];
The output should be:
The date is 10/14/2012.
please advise.
edsweng
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Yes
<?php
$age = "really really really old :)";
?>
<h1>You are <?php echo $age; ?></h1>
NOTE
The cuse of age in this post is no idictaion of being agest
Squidge
Posting Pro in Training
413 posts since Dec 2009
Reputation Points: 111
Solved Threads: 62
Skill Endorsements: 5
Well you can always concatenate your text or whatever.
$var = date('Y-m-d');
"The date is ".$var.";
szabizs
Junior Poster
126 posts since Jul 2009
Reputation Points: 8
Solved Threads: 15
Skill Endorsements: 0
I think the OP wants to know if he can store a PHP variable and a text string, in the mysql field. Presumably so that when he selects the data from the dbase, PHP parses the variable and changes it for the current date.
adam.adamski.96155
Junior Poster
189 posts since Oct 2012
Reputation Points: 43
Solved Threads: 40
Skill Endorsements: 4
Question Answered as of 7 Months Ago by
Squidge,
adam.adamski.96155
and
szabizs Don't bother guys, str_replace do the trick.
edsweng
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0