使用php查询无法正常工作

I really don't undestand what is happening in here, This the form that im using which ask for a studentcode = lz.

  <form action="classgrades.php?id=<?php echo $courseid ?>" method="post">
       <input type="text" name="studentCode" value="" placeholder="Student Code.." />
       <button type="submit" value="Submit">Submit</button> 
  </form>

and this query to select the data from the table

$studentcode = $_POST['studentCode']; 
 $query = "SELECT fname FROM students WHERE studentcode = $studentcode";

I don't undestand whay im getting this error

ErrorSQLSTATE[42S22]: Column not found: 1054 Unknown column 'lz' in 'where clause'

and if I try with a student code that is a number work, but not for letters

If you want to give characters as values, then you have to enclose it in quotes. Try with

$query = "SELECT fname FROM students WHERE studentcode = '$studentcode'";