How do I read values (PHP defined constants) from wp-config.php? - php

I need to get username, password etc from the wp-config file to connect to a custom PDO database.
Currently I have another file where I have this info, but I would like to only use the wp-config.
So how can I read the different properties of wp-config?

I have even defined my own constants in in wp-config.php and managed to retrieve them in theme without any includes.
wp-config.php
define('DEFAULT_ACCESS', 'employee');
functions.php
echo "DEFAULT_ACCESS :".DEFAULT_ACCESS;
outputs DEFAULT_ACCESS :employee

Here's some same code.
// ...Call the database connection settings
require( path to /wp-config.php );
// ...Connect to WP database
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if ( !$dbc ) {
die( 'Not Connected: ' . mysql_error());
}
// Select the database
$db = mysql_select_db(DB_NAME);
if (!$db) {
echo "There is no database: " . $db;
}
// ...Formulate the query
$query = "
SELECT *
FROM `wp_posts`
WHERE `post_status` = 'publish'
AND `post_password` = ''
AND `post_type` = 'post'
";
// ...Perform the query
$result = mysql_query( $query );
// ...Check results of the query and terminate the script if invalid results
if ( !$result ) {
$message = '<p>Invalid query.</p>' . "\n";
$message .= '<p>Whole query: ' . $query ."</p> \n";
die ( $message );
}
// Init a variable for the number of rows of results
$num_rows = mysql_num_rows( $result );
// Print the number of posts
echo "$num_rows Posts";
// Free the resources associated with the result set
if ( $result ) {
mysql_free_result( $result );
mysql_close();
}

I would just include the file then I would have access to the variable in it varibales.
<?php
require_once('wp-config.php');
echo DB_NAME;
?>
This is assuming you're on the same server and you can access wp-config.php through the file system.
If you're doing this for a plugin, these values are already available. You won't need to include the file again.

You can get all the global constants from wp-config.php simply echo the const like that:
<?php
echo DB_HOST;
echo DB_NAME;
echo DB_USER;
echo DB_PASSWORD;

Here is a function to read all WP DB defines:
function get_wordpress_data() {
$content = #file_get_contents( '../wp-config.php' );
if( ! $content ) {
return false;
}
$params = [
'db_name' => "/define.+?'DB_NAME'.+?'(.*?)'.+/",
'db_user' => "/define.+?'DB_USER'.+?'(.*?)'.+/",
'db_password' => "/define.+?'DB_PASSWORD'.+?'(.*?)'.+/",
'db_host' => "/define.+?'DB_HOST'.+?'(.*?)'.+/",
'table_prefix' => "/\\\$table_prefix.+?'(.+?)'.+/",
];
$return = [];
foreach( $params as $key => $value ) {
$found = preg_match_all( $value, $content, $result );
if( $found ) {
$return[ $key ] = $result[ 1 ][ 0 ];
} else {
$return[ $key ] = false;
}
}
return $return;
}
this returns an array like this:
array (size=5)
'db_name' => string '.........'
'db_user' => string '.........'
'db_password' => string '.........'
'db_host' => string 'localhost'
'table_prefix' => string 'wp_'

If you want to connect to DB, for current versions of PHP, using mysqli extention is recommended (mysql extention is going to deprecate):
require_once ("../wp-config.php"); // path to wp-config depends on your file locatoin
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

Just add required wp-load.php file.
you can use all wordpress functionality like
get_recent_posts() and many more...

Related

php, how to connect to a database as a class, send sql statments and return the result

Forgive me if the question is a little odd
I can clarify if needed:
I have the code that can connect to a mysql database as normal, however i have encapsulated it as a class:
<?php
define("HOST", "127.0.0.1"); // The host you want to connect to.
define("USER", "phpuser"); // The database username.
define("PASSWORD", "Secretpassword"); // The database password.
class DBConnection{
function conn($sql, $database){
$DB = new mysqli(HOST,USER,PASSWORD,$database);
if ($DB->connect_error){
die("Connection failed: " . $DB->connect_error);
exit();
}
if ($result = $DB->query($sql)){
return TRUE;
$DB->close();
}
else{
echo "Error: " . $sql . "<br>" . $DB->error;
$DB->close();
}
}
}
?>
I have done it this way so i can include this class in any subsequent php page and allow them to send it an sql statment and the database, see below as an example:
$sql = ("INSERT INTO users (first_name, last_name, username, email, password, group_level) VALUES ('John', 'Doah','JDoah', 'example#email', 'password', 'user')");
$DB = new DBConnection;
$result = $DB->conn($sql,"members");
if ($result ==TRUE){
return "Record added sucessfully";
}
This works fine.
however, im looking to send other sql statments to DBConnection.
How do i do that and to have it pass back any results that it recives? errors, boolean, row data etc. The caller will worry about parsing it.
Hopefully that makes sense.
This is an old class I used to use way back in the days of mysql still works but will need to be updated for mysqli or newer
class DBManager{
private $credentials = array(
"host" => "localhost",
"user" => "",
"pass" => "",
"db" => ""
);
function DBManager(){
$this->ConnectToDBServer();
}
function ConnectToDBServer(){
mysql_connect($this->credentials["host"],$this->credentials["user"],$this->credentials["pass"]) or die(mysql_error());
$this->ConnectToDB();
session_start();
}
function ConnectToDB(){
mysql_select_db($this->credentials["db"]) or die(mysql_error());
}
function Insert($tableName,$data){
$parameters = '';
$len = count($data);
$i = 0;
foreach($data as $key => $value){
if(++$i === $len){
$parameters .= $key . "='$value'";
}else{
$parameters .= $key . "='$value'" . ", ";
}
}
$query = "INSERT INTO $tableName SET $parameters";
mysql_query($query) or die(mysql_error());
return true;
}
function GetRow($tableName,$select,$where){
$selection = '';
$len = count($select);
$i = 0;
foreach($select as $key){
if(++$i === $len){
$selection .= $key;
}else{
$selection .= $key . ",";
}
}
$whereAt = '';
foreach($where as $key => $value){
$whereAt .= $key . "='$value'";
}
$query = "SELECT $selection FROM $tableName WHERE $whereAt";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
return $row;
}
}
}
The key things here is you can create a persistent connection to your database without rewriting a bunch of code
Example
global $DB;
$DB = new DBManager();
Since the connection happens in the constructor you will now have a connection on the page you call this code and can begin getting and setting to the database through use of $DB->GetRow() and $DB->Insert() which makes things much easier and was modeled after the $wpdb instance which is a class that manages the database in wordpress sites
Examples
For these examples we will assume you have a table as such
Insert new student
//create an associative array
$data = array(
"student_id" => 1,
"birth_date" => "02/06/1992",
"grade_level" => 4
);
//Send Call
$dm->Insert("student",$data);
Get data
//Create selection
$selection = array("grade_level");
//Create associative array for where we want to find the data at
$where = array(
"id" => 1
);
//Get Result
$result = $dm->GetRow("student",$selection,$where);
//do something with result
echo $result->grade_level;

How can I connect mssql server and get values with php

I'm a newbie on php and I try to make a calendar for people travel information from db and want to show these info on the calendar's day so my problem is to connect MSSQL Server and take the values form db.My php pages work on localhost(wampp) and my calendar view perfectly but cannot get the value from DB.It does not give an error.But can not pull data.Could you please help me to find my fault.Thanks.
connect.php;
<?php
class DBO
{
private $server = "servername";
private $db_name = "dbname";
private $password = "pass";
private $username = "username";
private $conn;
private $database;
function Connect()
{
$this->conn = mssql_connect($this->server, $this->username, $this->password)
or die("Couldn't connect to SQL Server on " . $this->server);
$this->database = mssql_select_db($this->db_name, $this->conn)
or die("Couldn't open database " . $this->db_name);
}
function RunSql($sqlQuery)
{
return mssql_query($sqlQuery);
}
}
?>
query code;
<?php
include_once("db_connect.php");
$DBO = new DBO();
$DBO->Connect();
$query = "SELECT ID, TYPE, STARTDATE, ENDDATE FROM TABLENAME";
$query_results = $DBO->RunSql($query)
or die('Error in $query_menu. Error code :' . mssql_get_last_message() );
$calendar = array();
while( $results = mssql_fetch_assoc($query_menu_results) )
{
$calendar[] = array('ID' =>$rows['ID'],'TYPE' => $rows['TYPE'],'url' => "#","class" =>'event-important','start' => "$start",'end' => "$end");
}
$calendarData = array(
"success" => 1,
"result"=>$calendar);
echo json_encode($calendarData);
exit;
?>
<?php
I believe you're issue is from executing the SQL via...
$query_results = $DBO->RunSql($query)
...but using it via...
while( $results = mssql_fetch_assoc($query_menu_results) )
Basically, $query_results becomes $query_menu_results.
I use a variant of this to test MsSQL connectivity:
<?php
// connect to the server
$dbconn = mssql_connect('SEVER_NAME_OR_IP', 'MsSQL-User', 'MsSQL-User-Password');
if (!$dbconn) {
$message='unable to connect to the database: ' . mssql_get_last_message();
die($message);
}
// select the database
if (!mssql_select_db('DATABASE_NAME', $dbconn)) {
die('Unable to select the database!');
}
// execute a query. NOTE: Never use string concatenation in SQL statements. EVER!!!
$sql = "select * from information_schema.tables;";
$query = mssql_query($sql, $dbconn);
// consume the results
echo "<table border='1'><tr><th>Column A</th><th>Column B</th></tr>";
while ($row = mssql_fetch_row($query)) {
echo "<tr><td>";
echo $row[0];
echo "</td><td>";
echo $row[1];
echo "</td></tr>";
}
echo "</table>";
// clean up
mssql_free_result($query);
mssql_close($dbconn);
?>
SECURITY NOTE: Last I check, The mssql* doesn't support prepared statements. Please see PDO or sqlsrv*. This Question has good info on MsSQL prepared statements.
Solution:
I've reproduced your code and I've found these errors:
include_once("db_connect.php"); must be include_once("connect.php");
while ($results = mssql_fetch_assoc($query_menu_results)) { must be while ($results = mssql_fetch_assoc($query_results)) {
'ID' =>$rows['ID'], must be 'ID' => $results['ID'],
'TYPE' => $rows['TYPE'], must be 'TYPE' => $results['TYPE'],
missing $start and $end variables;
Working example:
Example is based on your code. I've left your erros in comment. Table definition is just to make working query.
Database:
CREATE TABLE [dbo].[TABLENAME] (
[ID] [numeric](10, 0) NULL,
[TYPE] [numeric](10, 0) NULL,
[STARTDATE] datetime NULL,
[ENDDATE] datetime NULL
) ON [PRIMARY]
INSERT [TABLENAME] (ID, TYPE, STARTDATE, ENDDATE)
VALUES (1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
INSERT [TABLENAME] (ID, TYPE, STARTDATE, ENDDATE)
VALUES (1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
SELECT ID, TYPE, STARTDATE, ENDDATE
FROM [TABLENAME]
connect.php
<?php
class DBO {
private $server = "servername";
private $db_name = "dbname";
private $password = "pass";
private $username = "username";
private $conn;
private $database;
function Connect() {
$this->conn =
mssql_connect($this->server, $this->username, $this->password) or
die("Couldn't connect to SQL Server on " . $this->server);
$this->database =
mssql_select_db($this->db_name, $this->conn) or
die("Couldn't open database " . $this->db_name);
}
function RunSql($sqlQuery) {
return mssql_query($sqlQuery);
}
}
?>
query.php
<?php
//include_once("db_connect.php");
include_once("connect.php");
$DBO = new DBO();
$DBO->Connect();
$query = "SELECT ID, TYPE, STARTDATE, ENDDATE FROM [TABLENAME]";
$query_results =
$DBO->RunSql($query)
or die('Error in $query_menu. Error code :' . mssql_get_last_message() );
$calendar = array();
//while ($results = mssql_fetch_assoc($query_menu_results)) {
while ($results = mssql_fetch_assoc($query_results)) {
$calendar[] = array(
//'ID' =>$rows['ID'],
'ID' => $results['ID'],
//'TYPE' => $rows['TYPE'],
'TYPE' => $results['TYPE'],
'url' => "#",
"class" => 'event-important',
//'start' => "$start",
//'end' => "$end"
);
}
$calendarData = array(
"success" => 1,
"result"=>$calendar
);
echo json_encode($calendarData);
exit;
?>
Output:
{
"success":1,
"result":[
{"ID":"1","TYPE":"1","url":"#","class":"event-important"},
{"ID":"1","TYPE":"1","url":"#","class":"event-important"}
]
}

PHP: How to use string variable as table in sql query (PDO)

I would like to make a general function to select last inserted id's of different tables.
I already tried multiple things, this might be the best effort (in db.inc.php);
<?php
define( 'DB_HOST', 'localhost' );
define( 'DB_NAME', 'modlar' );
define( 'DB_USER', 'root' );
define( 'DB_PASS', 'password' );
function verbinden(){
$verbinding = 'mysql:host=' . DB_HOST . ';DB_NAME=' . DB_NAME;
$db = null;
try{
return new PDO( $verbinding, DB_USER, DB_PASS );
}catch( PDOException $e ){
return NULL;
}
}
function loopdoor( $naam, $ding){
$regels = '';
if( is_array($ding) || is_object($ding)):
$wat = (is_array($ding)? 'array' : 'object');
$regels .= '<strong>'.$naam.'['.$wat.']</strong><ul>';
foreach( $ding as $k => $v):
$regels .= loopdoor( $k, $v);
endforeach;
$regels .= '</ul>';
else:
$regels .= '<li><strong>'.$naam.'</strong> => '.$ding.'</li>';
endif;
return $regels;
}
function last_id( &$db , $table, $column){
if( is_null( $db ) ) return array();
$sql = "
SELECT
max(modlar.table.column)
FROM
modlar.table";
$vraag = $db->prepare( $sql );
$vraag->bindValue( ':table', $table, PDO::PARAM_STR );
$vraag->bindValue( ':column', $column, PDO::PARAM_STR );
$vraag->execute();
return $vraag->fetchAll( PDO::FETCH_OBJ );
}
Where modlar is my database. And my variables (in db.php);
<?php
require_once 'db.inc.php';
// Verbinden met database
$db = verbinden();
if( is_null($db))
die('<h1>Error</h1>');
echo 'done';
$table = 'time';
$column = 'time_id';
$last = last_id($db, $table, $column);
echo '<ul>'.loopdoor('all data', $last).'</ul>';
?>
But I dont get any data on my screen (and no error). However, when I add the variables directly to the code, I'll get the last id of that table. So like;
$sql = "
SELECT
max(modlar.time.time_id)
FROM
modlar.time";
What is going wrong?

Do not reconnect the database for controler call

My controler call a method who is requested the database and return the result.
$connect = $this->connectBDD();
$rq = "SELECT naf, libelle FROM mytable WHERE naf ILIKE '$txt%'";
$t = $connect->prepare($rq); $t->execute();
$t->setFetchMode(\PDO::FETCH_OBJ);
$tab = array();
while($top = $t->fetch()) {
$tab[] = array(
"text" => $top->naf . ": " . $top->libelle,
"value" => $top->naf
);
}
$t->closeCursor();
return $tab;
The problem comes from the first line $connect = $this->connectBDD(); who open the connexion. It takes times, ~ 1 seconde, and because this method is call very often (auto completion system), I need to memorize the connection to not reconnect at each call.
I try to memorize $connect in session
if( null === $this->app['session']->get('ac') ) {
$this->app['session']->set('ac', $this->connectBDD() );
}
$connect = $this->app['session']->get('ac');
$rq = "SELECT naf, libelle FROM mytable WHERE naf ILIKE '$txt%'";
$t = $connect->prepare($rq); $t->execute();
$t->setFetchMode(\PDO::FETCH_OBJ);
$tab = array();
while($top = $t->fetch()) {
$tab[] = array(
"text" => $top->naf . ": " . $top->libelle,
"value" => $top->naf
);
}
$t->closeCursor();
return $tab;
But it's worse, as if I have an infinite loop...
So, how can I call my method without reconnect the database at each call ?
Thanks for help
Try to make persistent connection in connectBDD
$dbh = new PDO('....', $user, $pass, array(
PDO::ATTR_PERSISTENT => true
));
http://php.net/manual/en/pdo.connections.php

OOP php error in database connection

i'm new to OOP so i'm following a tutorial. so in that it uses following codes to connect to the database but in my case it is not connecting
databas.php
<?php
require_once("config.php");
class MySQLDatabase {
private $connection;
function __construct() {
$this->open_connection();
}
public function open_connection() {
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
if (!$this->connection) {
die("Database connection failed: " . mysql_error());
} else {
$db_select = mysql_select_db(DB_NAME, $this->connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
}
}
public function close_connection() {
if(isset($this->connection)) {
mysql_close($this->connection);
unset($this->connection);
}
}
public function query($sql) {
$result = mysql_query($sql, $this->connection);
$this->confirm_query($result);
return $result;
}
public function mysql_prep( $value ) {
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0
if( $new_enough_php ) { // PHP v4.3.0 or higher
// undo any magic quote effects so mysql_real_escape_string can do the work
if( $magic_quotes_active ) { $value = stripslashes( $value ); }
$value = mysql_real_escape_string( $value );
} else { // before PHP v4.3.0
// if magic quotes aren't already on then add slashes manually
if( !$magic_quotes_active ) { $value = addslashes( $value ); }
// if magic quotes are active, then the slashes already exist
}
return $value;
}
private function confirm_query($result) {
if (!$result) {
die("Database query failed: " . mysql_error());
}
}
}
$database =& new MySQLDatabase();
$db =& $database;
?>
config.php
<?php
// Database Constants
defined('DB_SERVER') ? null : define("DB_SERVER", "localhost");
defined('DB_USER') ? null : define("DB_USER", "oop_project");
defined('DB_PASS') ? null : define("DB_PASS", "");
defined('DB_NAME') ? null : define("DB_NAME", "oop_project");
?>
function.php
<?php
function strip_zeros_from_date( $marked_string="" ) {
// first remove the marked zeros
$no_zeros = str_replace('*0', '', $marked_string);
// then remove any remaining marks
$cleaned_string = str_replace('*', '', $no_zeros);
return $cleaned_string;
}
function redirect_to( $location = NULL ) {
if ($location != NULL) {
header("Location: {$location}");
exit;
}
}
function output_message($message="") {
if (!empty($message)) {
return "<p class=\"message\">{$message}</p>";
} else {
return "";
}
}
?>
when i going to test the connection
i got these errors.
Deprecated: Assigning the return value of new by reference is deprecated in J:\xampp\htdocs\oop_project\includes\database.php on line 60
Deprecated: Assigning the return value of new by reference is deprecated in J:\xampp\php\PEAR\Config.php on line 80
Deprecated: Assigning the return value of new by reference is deprecated in J:\xampp\php\PEAR\Config.php on line 166
Notice: Use of undefined constant DB_SERVER - assumed 'DB_SERVER' in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Notice: Use of undefined constant DB_USER - assumed 'DB_USER' in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Notice: Use of undefined constant DB_PASS - assumed 'DB_PASS' in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://DB_SERVER:3306) in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in J:\xampp\htdocs\oop_project\includes\database.php on line 13
Database connection failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
how can i correct this...? thank you.
The "deprecated" warnings are because you're using
$database =& new MySQLDatabase();
replace with
$database = new MySQLDatabase();
The notices are because it seems the constants (DB_SERVER, ...) are not defined before you try and instantiate the class (new MySQLDatabase). Make sure config.php is loaded before.
The other warnings are connected to those same issues.
The include for config.php is actually including
J:\xampp\php\PEAR\Config.php
not your local config file.
It seems that something is incorrect with your DB_SERVER, DB_USER, DB_PASS variables or something is wrong with your server? You should definitely invest time in trying the example without your deprecated oop classes.
But, first try changing your $database =& new MySQLDatabase();
to a cleaner $database = new MySQLDatabase();
If you wanted to move over to PDO then here is a quick example of what I think your trying to achieve. A CreateReadUpdateDelete (CRUD) class.
<?php
class MySQLDatabase{
public $db;
function __construct($dsn, $user=null, $pass=null){
$this->dsn = $dsn;
$this->user = $user;
$this->pass = $pass;
//Connect
$this->connect();
}
function connect(){
try{
$this->db = new PDO($this->dsn, $this->user, $this->pass);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
}catch (Exception $e){
die('Cannot connect to databse. Details:'.$e->getMessage());
}
}
function Select($table, $fieldname=null, $fieldvalue=null){
$sql = "SELECT * FROM $table";
$sql .=($fieldname != null && $fieldvalue != null)?" WHERE $fieldname=:id":null;
$statement = $this->db->prepare($sql);
if($fieldname != null && $fieldvalue != null){$statement->bindParam(':id', $fieldvalue);}
$statement->execute();
return $statement->fetchAll(PDO::FETCH_ASSOC);
}
function Insert($table, $values){
$fieldnames = array_keys($values[0]);
$sql = "INSERT INTO $table";
$fields = '( ' . implode(' ,', $fieldnames) . ' )';
$bound = '(:' . implode(', :', $fieldnames) . ' )';
$sql .= $fields.' VALUES '.$bound;
$statement = $this->db->prepare($sql);
foreach($values as $vals){
$statement->execute($vals);
}
}
function Update($table, $fieldname, $value, $where_key, $id){
$sql = "UPDATE `$table` SET `$fieldname`= :value WHERE `$where_key` = :id";
$statement = $this->db->prepare($sql);
$statement->bindParam(':id', $id);
$statement->bindParam(':value', $value);
$statement->execute();
}
function Delete($table, $fieldname=null, $id=null){
$sql = "DELETE FROM `$table`";
$sql .=($fieldname != null && $id != null)?" WHERE $fieldname=:id":null;
$statement = $this->db->prepare($sql);
if($fieldname != null && $id != null){$statement->bindParam(':id', $id);}
$statement->execute();
}
}
//Sample Usage
$db = new MySQLDatabase('mysql:host=localhost;dbname=test','root','password');
//Multi insert:
$insert = array(array('some_col'=>'This was inserted by the $db->Insert() method'),
array('some_col'=>'Test insert 2'),
array('some_col'=>'Test insert 3'),
);
$db->Insert('pdo_test', $insert);
//Select All
$result = $db->Select('pdo_test');
/*
Array
(
[0] => Array
(
[id] => 2
[some_col] => This was inserted by the $db->Insert() method
)
[1] => Array
(
[id] => 3
[some_col] => Test insert 2
)
[2] => Array
(
[id] => 4
[some_col] => Test insert 3
)
)
*/
//Single select
$result = $db->Select('pdo_test','id','2');
/*
Array
(
[0] => Array
(
[id] => 2
[some_col] => This was inserted by the $db->Insert() method
)
)
*/
/* Delete Single record*/
$db->Delete('pdo_test', 'id', '2');
/*Delete All*/
$db->Delete('pdo_test');
//Array ( )
$result = $db->Select('pdo_test');
?>
Best solution is goto php.ini
allow_url_include = On
and save
or
use
inlcude 'J:\xampp\htdocs\oop_project\includes\database.php';
require_once 'J:\xampp\htdocs\oop_project\includes\database.php';
As per require this will resolve the
php_network_getaddresses: getaddrinfo failed: No such host is known.

Categories