Firstly, you could and should use wpdb to connect to another database. E.g. like this:
$the_other_db = new wpdb(
'username',
'password',
'database',
'localhost'
);
$results = $the_other_db->get_results( $sql );
Take a look at Using wpdb to connect to a separate database for more information.
Secondly, like @AndrewBartel said it’s likely the plugin. Besides IMHO – not insult intended – inputting PHP code like this into the templating area will always be pretty awful. So going with a custom template and some class(es) and/or function(s) for your functionality would just be the much better approach.
Related Posts:
- How to properly insert data into custom table via plugin
- Searching users with WP_List_Table plugin
- How to write one comment and publish on every post using database or plugin?
- How to get number of Affected rows from wordpress dbDelta() function
- Display data on Word Press site posts and pages from mysql table
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- WpDataTables – View Image Directory
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- pagination on data fetched using SQL query
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- How can I fetch data from another website to my wordpress website with mysql database
- speed up pagination for huge database
- Way to send multiple values for column to MySQL?
- How to display results from a data table with an encrypted user id?
- Check against server time to display SQL entries – Radio Station DJ Rotator Plugin
- add_action for publish_post doesn’t work
- WordPress Cache delete on plugin uninstall
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Getting current user data with MySQL statement
- How to get the custom field value using SQL query
- WP Function does not trigger on Webhook API Call
- Cant create table on plugin activation
- How to get database connection details without longing to cpanel in WordPress?
- Moving a few select DB tables to a new WP instance
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- get/show Last ID
- MySql Query for WordPress
- how to search through plugin in wordpress cimy-user-extra-fields?
- PHP Creating a formula from mysql db values and db stored math operator
- Split Million WordPress Post’s Into Multiple Database Server
- Getting 504 Gateway Timeout Error on AWS Server! [closed]
- WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there
- How can I use WordPress functions in my stylesheet?
- WP showing “warning: call_user_func_array()”, What to do?
- How can I pass a variable to wp_ajax action?
- How can i change an image’s author?
- Creating search filter through plugin
- WP-Members redirect if member ALREADY logged in
- How to edit/delete single row items in a table on my own menu page
- Get a list of galleries from an album in NextGEN Gallery [closed]
- Undefined property: WP_Post_Type::$ID
- Plugin exceeds memory limit
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- Preferred way of cacheing a value in php
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- Automatically add attributes to woocommerce product?
- Edit Yoast SEO breadcrumbs output [closed]
- Adding a slider captcha to the comment system
- How to put JQuery/Ajax inside shortcode?
- Query all customers/users and check for duplicate information
- WordPress function not being called from jQuery method
- wp_remote_get() returns 403 while file_get_contents() does not
- how to access all user dashboard on fronted page [closed]
- WordPress Widget Not Saving Data
- Center and hide overflow of WP toolbar custom links
- How I can internationalize variables within the function _e () __ (), etc?
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- Basic function call on init failing
- Help with WP Business Directory Manager Plugin?
- get specific value of a array | PHP
- I receive taxonomy id
- Is there a way to convert shortcodes to html content?
- DB Query not working in Plugin
- How to change WooCommece variation data programmtically [closed]
- dynamically create callback functions inside a for loop
- WordPress truncate posts question (plugin related)
- Different registration form for different roles
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Use a hook or filter, or overwrite this Gamipress function?
- My CPU usage in A2 Hosting Shared Plan (Turbo Boost) is high due to mysql query!
- What database state changes happen after a post is manually “updated” with no changes?
- The Build menu theme is frozen with the wordpress theme
- Does anyone know why my SEO and title become one?
- Get Shortcode output to database for static post_content
- SimpleXML is not working with xml response from external api
- strtotime not working
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- How To Toggle User_Meta in frontend in a form using PHP
- Change Woo Custom Endpoint Titles from a Plugin
- No result after wpdb->insert
- Optimized PHP & WordPress settings for speed/performance?
- Speeding up WordPress on a Local Network
- How can I store user preferences in WordPress and retreive them later?
- How to add php plugin code in theme
- how change my menu on submenu
- Plugin debugging with errors in activation routine
- Number format in thousands on highcharts in wpdatatable plugin
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- W3 Total Cache Can’t Really Detect Things
- How do I add php to all links automatically?
- Plugin use of ajax/jquery depending dropdown
- Creating Features List in WordPress Post
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Posts in Admin only display 1 Post instead of all Post in admin area
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Creating a Table Row by Row
- WordPress Throwing Deprecated Errors on its own Files