How to fix: Warning: mysqli_query() expects parameter 1 to be mysqli?
$link = mysqli_connect($DB_HOST, $user, $pass, $dbName);
mysqli_query($link, 'CREATE TEMPORARY TABLE `table`');
With mysqli you need to save the connection in variable and provide that for every time you use mysqli.
EDIT: generally: You need to provide the connection for every mysqli-related function you use.
mysqli_query() expects parameter 1 to be mysqli, string given in
Modify your db connect class to maintain the connection:
class DB_CONNECT {
protected $connection = null;
// constructor
function __construct() {
// connecting to database
$this->connection = $this->connect();
}
// destructor
function __destruct() {
// closing db connection
$this->close();
}
/**
* Function to connect with database
*/
function connect() {
// import database connection variables
require_once __DIR__ . '/db_config.php';
// Connecting to mysql database
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE) or die(mysqli_error());
// Selecing database
$db = mysqli_select_db($con,DB_DATABASE) or die(mysqli_error()) or die(mysqli_error());
// returing connection cursor
return $con;
}
public function getConnection() {
return $this->connection;
}
/**
* Function to close db connection
*/
function close() {
// closing db connection
}
}
Then modify your query line to:
if (mysqli_query($db->getConnection(), $result)) {
Related Topics
Trying to Get Laravel 5 Email to Work
Setting PHP Tmp Dir - PHP Upload Not Working
Setcookie() Does Not Set Cookie in Google Chrome
Laravel Error: Missing Required Parameters for Route
Why Is Constructing Pdo Connection Slow
Getting Complete Path of Uploaded File - PHP
Storing Arrays in the Database
A Conditional Element Inside an Array(...) Construct
Too Much Data with Var_Dump in Symfony2 Doctrine2
Why Does Crypt/Blowfish Generate the Same Hash with Two Different Salts
Access Variables from Parent Scope in Anonymous PHP Function