We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,983 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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.

4
Contributors
4
Replies
22 Hours
Discussion Span
7 Months Ago
Last Updated
5
Views
Question
Answered
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

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0698 seconds using 2.7MB