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 Link to comment https://forums.phpfreaks.com/topic/278546-parse-error-syntax-error/ 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 Link to comment https://forums.phpfreaks.com/topic/278546-parse-error-syntax-error/#findComment-1432929 Share on other sites More sharing options...
guybrown Posted May 29, 2013 Author 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. Link to comment https://forums.phpfreaks.com/topic/278546-parse-error-syntax-error/#findComment-1432932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.