Solved

Wordpress Database

Posted on 2015-02-11
2
62 Views
Last Modified: 2015-02-11
Is it possible to sidestep the $wpdb class (for accessing the WP database) and just use plain old MySQL queries constructed in php?

I'm talking SPECIFICALLY about accessing tables I added to the WP database.

If the answer is yes, how do I get the WP connect string data (host, user name, dbname & password)?

Thanks
0
Comment
Question by:Richard Korts
2 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40604307
Yes, same as any php connection to a MySql database:
// LOCAL CONNECT TO THE DATABASE
$DB_NAME = 'myDatabase';
$DB_HOST = 'localhost';
$DB_USER = 'testuser';
$DB_PASS = 'myPassword';


$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);


if (mysqli_connect_errno()) {
	printf("Connect failed: %s\n", mysqli_connect_error());
	exit();
}

Open in new window

Get your connection string information from the wp-config.php file.
0
 

Author Closing Comment

by:Richard Korts
ID: 40604457
Thanks, I figured out the location (in wp_config) myself. Looks pretty simple.

But based on the other question / result, I will probably try to forge on with $wpdb.

Thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you are looking for plug-ins to add functions to your WordPress small business web site, take some time to read though this comprehensive list.  These are all the plugins I use for my customers WordPress web sites, as well as my own.  Be sure to …
WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question