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.

Recommended Answers

All 4 Replies

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

Well you can always concatenate your text or whatever.

$var = date('Y-m-d');

"The date is ".$var.";

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.

Don't bother guys, str_replace do the trick.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.