connecting to DB from custom php file

You’re must load WP-load function To do that you need to require wp-load file, so if, your custom file is in theme it shoudl look like somethink like that: $wp_load = ‘../../../../../wp-load.php’; if ( file_exists( $wp_load ) ) { require_once( $wp_load ); }else{ die(‘no-load’); } You could also set const SHORTINIT to true to minimalize … Read more

Update MySQL query so that it functions again

mysql_fetch_object() was deprecated in PHP 5.5 and fully removed in PHP 7.0, which is probably why it no longer works for you. It’s always better to use WP functions – often they are wrappers for something in PHP (or elsewhere), but by using the WP wrapper version, it usually protects you from deprecation (since the … Read more

Is it possible to create a WordPress table using array and loop?

This is a code review question more than a WordPress question. Please post these in the Code Review Stack Exchange in the future. You have a couple things wrong or not according to best practices. Comments inline for where I made changes. $cr_table_array = array( array( ‘data_field’ => ‘id’, // Add primary key here to … Read more

WordPress plugins for database queries

I don’t know of a plugin that allows you to do this out of the box, but as you are (/seem to be) comfortable with database manipulation, I’ve outlined below how you can achieve what you want using custom coding. You can run custom queries using the wpdb-class. There are a few posts on WPSE/SO … Read more

Error establishing a database connection,

Maybe if you configured the wp-config.php file like the documentation says (see https://wordpress.org/support/article/editing-wp-config-php/ ) Sample wp-config.php file (database section), per the above link: // ** MySQL settings – You can get this info from your web host ** // /** The name of the database for WordPress */ define( ‘DB_NAME’, ‘database_name_here’ ); /** MySQL database … Read more