$wpdb selects wrong database
$_SERVER[‘DOCUMENT_ROOT’]; is not going to include secondsite. So all the files, including wp-config.php with the database details, are coming from the root public directory. To get the current directory, including subdirectories, use any of these: getcwd(); dirname(__FILE__); basename(__DIR__); But if your file is in a deeper folder, you can’t find the secondsite directory without specifying … Read more