guybrown Posted May 29, 2013 Share Posted May 29, 2013 Hi all I'm new to programming and this forum and know very little about php. Any help would be greatly appreciated and I look forward to contributing and supporting others as my knowledge increases. I am trying to get a 'counter' php file working on my localhost. When I run the php file in chrome I get the following error: Parse error: syntax error, unexpected '$result' (T_VARIABLE), expecting ',' or ';' in C:\xampp\htdocs\database\counter.php on line 8 My php file contains the following: <?php require($_SERVER["DOCUMENT_ROOT"]."/database/config/db_config.php"); $connection = @mysql_connect($db_host,$db_user, $db_password) or die("error connecting"); mysql_select_db($db_name, $connection); $query = "SELECT * FROM counter"; echo $query $result = mysql_query($query, $connection) or die(mysql_error()); echo $result $views = mysql_result($result, 0, "num_views"); echo $views $views++; $query = "UPDATE counter SET num_views = $views"; mysql_query($query, $connection) or die(mysql_error()); echo "This page has been viewed ".$views." times."; ?> I created the counter table in phpmyadmin and it has the following details: # Name Type Collation Attributes Null Default Extra Action 1 num_views int(5) UNSIGNED No 0 Change Drop Browse distinct values Any help appreciated. Regards, Guy Brown counter.php Quote Link to comment Share on other sites More sharing options...
PravinS Posted May 29, 2013 Share Posted May 29, 2013 Add semicolon( on lines echo $query echo $result echo $views Quote Link to comment Share on other sites More sharing options...
Solution guybrown Posted May 29, 2013 Author Solution Share Posted May 29, 2013 Add semicolon( on lines echo $query echo $result echo $views Much appreciated pbs! Thank you very much. The echoes that were there to help me identify any issues were causing the issues. Cheers, Guy. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.