Sorry about previous post (some stupid shortcut key made it send) Your row: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); should be: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0')"; You missed the double quotes. Adam --- Original Message --- Hi, for some reason i'm getting an error when I try to run this query: __________________________________ $sql="SELECT num FROM count where dept='$dept' AND deptsub='$deptsub'"; $page_count = mysql_query($sql,$db); # If does not exist in the database, insert a new entry if (!mysql_num_rows($page_count)){ $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); $result = mysql_query($sql,$db); } #Update the count in the database $page_count = $page_count + 1; $sql="UPDATE count SET num='$page_count' WHERE dept='$dept' AND deptsub='$deptsub'"; $result = mysql_query($sql, $db); __________________________________ My table looks like this: count: dept VARCHAR(32) deptsub VARCHAR(32) num INT(10) __________________________________ I'm getting the following error message: Parse error: parse error in /home/...../public_html/public/index.php on line 25 (Which is the line: $sql="UPDATE count...) Any thoughts would b most helpful. Thanks, Gav