Skip to main content
1 of 2

wpdb->get_row is selecting the variable as a column name

I'm using wpdb to get a row of a table

$file = $wpdb->get_row( "SELECT *
                         FROM {$wpdb->prefix}vip_files 
                         WHERE {$file_hash} = `hashcode`" );

and the error is: [Unknown column '4075c8514267d7926cd7f0cde577da2c' in 'where clause'] SELECT * FROM wp_vip_files WHERE 4075c8514267d7926cd7f0cde577da2c = hashcode

4075c8514267d7926cd7f0cde577da2c is the value of $file_hash

it is using the variable as a column name. if I put the value instead of variable, it will work but with variable I get error.