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.


--- Original Message ---


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
  $result = mysql_query($sql, $db);

My table looks like this:
     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.

Reply via email to