1) the way you build the $sql variable, the data you are passing is not quoted. Therefore SQL interprets it as a column name. Therefore your error message
2) You need to quote data you pass in an SQL statement. The problem is that by building your SQL statements that way, you are opening yourself up to SQL injection attacks
3) Use parameterized queries (aka prepared statements) to pass SQL statements and there corresponding values to your SQL server. It’s more work, but it’s worth it from a security perspective. See
https://websitebeaver.com/prepared-statements-in-php-mysqli-to-prevent-sql-injection