expected unqualified-id before 'if'

  lcd.begin(16, 2);{

Why is that curly brace there?

  if( Serial.available() )       // if data is available to read
  {;}

If there is data to read, do nothing. Otherwise, no nothing. Why?

  val = Serial.read();         // read it and store it in 'val'

Even if there isn't any. Why?

if( val =='z' )

buzz(10, 700, 500);

void buzz(int targetPin, long frequency, long length) {
  long delayValue = 1000000/frequency/2;


  long numCycles = frequency * length/ 1000;

You can't have code that is not in a function.