Trouble with SQL SELECT inside switch_to_blog()

Edit: You have an extra underscore in your table name, it becomes wp__posts in your case. Better use like how I have shown below 🙂


First, use table names like the following and try var_dump to see if it returns NULL. In case the Post ID doesn’t exist, $product will be NULL, which only var_dump can show.


$product = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = 4253");
var_dump( $product );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)