Jump to content

Parse error: syntax error

Go to solution Solved by guybrown,

Recommended Posts

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:



$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
$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   dot.gif Change dot.gif Drop dot.gif Browse distinct values


Any help appreciated.




Guy Brown


Link to comment
Share on other sites

  • Solution

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
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

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.