Issue with echo-ing the same variable twice in the same string...

Hi All,

I was wondering if anybody could help?

$TheStockDate = date(“Ymd”);

$format_day = substr($TheStockDate, 6, 2);
$format_mon = substr($TheStockDate, 4, 2);
$format_year = substr($TheStockDate, 0, 4);

$TheStockPeriod = "$format_day/$format_mon/$format_year TO $format_day/$format_mon/$format_year";


Inside an IF statement I have the above…

When it inserts $TheStockPeriod into my database it shows as “$”.
If I change the line to:

[php]$TheStockPeriod = “$format_day/$format_mon/$format_year TO”;[/php]

Then it shows correctly as “04/03/2011 TO”

It appears not to like me echoing the same variable twice…

Is there anyway I can fix this?


Hi there,

See if the same problem occurs when you concatenate the variables with the string:
[php]$TheStockPeriod = $format_day."/".$format_mon."/".$format_year." TO “.$format_day.”/".$format_mon."/".$format_year;

Also, put the following line above the if statement, see what (if any) errors you get:

Sponsor our Newsletter | Privacy Policy | Terms of Service