Skip to main content
Format error as code block, which I think it better than a quote here
Source Link
Rup
  • 4.4k
  • 4
  • 28
  • 29

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

[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.

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.

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.

Source Link

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.