Can anyone help me with this? I have tried everything I know but it doesn't work. I have this in my localhost, but everything went fine. When I transferred this online, this problem occurs. It would be great if someone could help me fix this. Thank you so much.
`<?php
require_once(LIB_PATH.DS."config.php");
class Database {
var $sql_string = '';
var $error_no = 0;
var $error_msg = '';
private $conn;
public $last_query;
private $magic_quotes_active;
private $real_escape_string_exists;

function __construct() {
	$this->open_connection();
	$this->magic_quotes_active = get_magic_quotes_gpc();
	$this->real_escape_string_exists = function_exists("mysqli_real_escape_string");
}

 public function open_connection() {
	$this->conn = mysqli_connect(DB_SERVER,DB_USER,DB_PASS);
	if(!$this->conn){
		echo "Problem in database connection! Contact administrator!";
		exit();
	}else{
		$db_select = mysqli_select_db(DB_NAME,$this->conn); */I got the error in this line/*
		if (!$db_select) {
			echo "Problem in selecting database! Contact administrator!";
			exit();
		}
	}`

    Well...you didn't try everything. 😉 I suspect you'll get past that problem if you transpose the two arguments to mysql_select_db() so that the mysqli connection is first, as per https://www.php.net/mysqli_select_db .

      I am just new to php. I just did what I know less about php. But anyway, thanks for the help. I would like to figure this out how to do what you suggest.

        Well, I thought I told you, but if you're really new and don't understand the terminology...

        I the link I provided to the manual page for the mysqli_select_db() function, note the order of the two arguments (a.k.a. parameters) that are between the parentheses. The first one is the MySQLi connection or "link" object, the second one is the name of the database. Now look at your code:

        $db_select = mysqli_select_db(DB_NAME,$this->conn); 
        

        You have them in the opposite order, so you just need to swap their order:

        $db_select = mysqli_select_db($this->conn, DB_NAME); 
        
          Write a Reply...