Hellusius Posted September 2, 2006 Share Posted September 2, 2006 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? Link to comment https://forums.phpfreaks.com/topic/19458-error-with-variables/ Share on other sites More sharing options...
wildteen88 Posted September 2, 2006 Share Posted September 2, 2006 You forgot to close your first echo statement:echo "<font color=\"#EFDFA0\">Statistics[nobbc]<br />[/nobbc][color=red][b]"[/b][/color]; Link to comment https://forums.phpfreaks.com/topic/19458-error-with-variables/#findComment-84508 Share on other sites More sharing options...
Hellusius Posted September 2, 2006 Author Share Posted September 2, 2006 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 Link to comment https://forums.phpfreaks.com/topic/19458-error-with-variables/#findComment-84509 Share on other sites More sharing options...
wildteen88 Posted September 2, 2006 Share Posted September 2, 2006 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] Link to comment https://forums.phpfreaks.com/topic/19458-error-with-variables/#findComment-84510 Share on other sites More sharing options...
Hellusius Posted September 2, 2006 Author Share Posted September 2, 2006 That works, Thank you very very much :) Link to comment https://forums.phpfreaks.com/topic/19458-error-with-variables/#findComment-84523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.