0

I am trying to get a php file to input content into the wordpress database under a specific table. I have set up the table and have verified that the information is passed into the insert.php file. THe issue is that I can not include the global $wpdb and when i call for a required once on the wp_config file or the other required files it gives me this error in the php logs:

[22-Aug-2015 18:07:03 Europe/Berlin] PHP Fatal error: require_once(): Failed opening required 'http://explorejeff.city/site1/wp-config.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\site1\wp-content\plugins\fbg-manager\inc\insert.php on line 8

I imagine it has to do with the insert.php file not being localized, however I am not familiar with how to localize a php file to allow for required php files to be included.

Insert.php

<?php
$url = 'http://'.$_SERVER['HTTP_HOST'];

global $wpdb;

 if(!isset($wpdb))
{
require_once($url.'/site1'.'/wp-config.php');
require_once($url.'/site1'.'/wp-load.php');
require_once($url.'/site1'.'/wp-includes/wp-db.php');
} 

$groupid= $_POST['groupid'];
$groupname = $_POST['groupname'];

error_log(print_r($url,true), 3, "my_errors.log");

$user_ID = get_current_user_id();
$settings = $wpdb->prefix . "fbg_manager_settings"; 

$wpdb->insert( 
    $settings, 
    array( 
        'userid' => $user_ID, 
        'groupid' => $groupid,
        'groupname' => $groupname,      
    ) );

?>
0

It had to do with the file path for the required items

I found an answer at this location that got it to work:

https://stackoverflow.com/questions/5647075/fatal-error-require-once-function-require-failed-opening-required

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.