Jump to content

Archived

This topic is now archived and is closed to further replies.

Hellusius

Error with variables

Recommended Posts

I am trying to sum two variables, but it gives me the following error

[code]Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/www/warnicro.awardspace.com/stats.php on line 3[/code]

The php code is

[code]<?
echo "<font color=\"#EFDFA0\">Statistics<br />;
$count = file_get_contents("count.txt");
$count2 = file_get_contents("count2.txt");
echo "<font color=\"#EFDFA0\">Homepage views: ".trim($count);
echo "<font color=\"#EFDFA0\">Total page view: ".trim($count) + ($count2);
?>  [/code]

Anyone see what I am doing wrong?

Share this post


Link to post
Share on other sites
You forgot to close your first echo statement:
echo "<font color=\"#EFDFA0\">Statistics[nobbc]<br />[/nobbc][color=red][b]"[/b][/color];

Share this post


Link to post
Share on other sites
thank you.
with that solved I bumped into another problem which is I want them to sum up but instead the are placed behind one another so the answer is 15315 while it should be 168

Share this post


Link to post
Share on other sites
Use this:
[code=php:0]echo "<font color=\"#EFDFA0\">Statistics<br />";
$count = file_get_contents("count.txt");
$count2 = file_get_contents("count2.txt");

echo "<font color=\"#EFDFA0\">Homepage views: " . trim($count) . "</font><br />";
echo "<font color=\"#EFDFA0\">Total page view: " . (trim($count) + $count2);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.