Unknown column in 'where clause'
You need to run DESC state_master;. This will show you all the columns in that table.

Fine the correct column name for the state name. Evidently, from the error, it is not State_name. Then, use that correct column name in the SQL Statement.

If State_Name is the actual column name, then try lowercase on all column names

$result = mysql_query("SELECT state_Id FROM state_master WHERE state_name='$statename'") or die(mysql_error());
$row=mysql_fetch_assoc($result);
return $row['state_Id'];


Give it a Try !!!