Your arguments are in the wrong order. The connection comes first according to the docs
<?php require("constants.php"); // 1. Create a database connection $connection = mysqli_connect(DB_SERVER,DB_USER,DB_PASS); if (!$connection) { error_log("Failed to connect to MySQL: " . mysqli_error($connection)); die('Internal server error'); } // 2. Select a database to use $db_select = mysqli_select_db($connection, DB_NAME); if (!$db_select) { error_log("Database selection failed: " . mysqli_error($connection)); die('Internal server error'); } ?>
Related Posts:
- Should I use mysqli_real_escape string() or mysql_real_escape_string() for form data?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in
- mysqli_real_connect(): (HY000/2002): No such file or directory
- Fatal error: Call to undefined function mysqli_connect()
- mysqli_real_connect(): (HY000/2002): No such file or directory
- Fatal error: Call to undefined function mysqli_connect()
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- MySqli Commands out of sync; you can’t run this command now
- Commands out of sync; you can’t run this command now
- Call to undefined method mysqli_stmt::get_result
- Call to undefined method mysqli_stmt::get_result
- Fatal error: Cannot use object of type mysqli_result
- How to solve “Fatal error: Class ‘MySQLi’ not found”?
- mysql_field_name to the new mysqli
- mysqli::query(): Couldn’t fetch mysqli
- phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user ‘pma’@’localhost’ (using password: NO)
- Warning: mysqli_query() expects at least 2 parameters, 1 given. What? [duplicate]
- Deprecated: mysql_query() [duplicate]
- Object of class mysqli_result could not be converted to string
- Fatal error: Call to a member function fetch_assoc() on a non-object
- Having a problem getting mysqli_query to execute
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given… what I do wrong?
- Call to a member function fetch_assoc() on boolean in
[duplicate] - PHP variables don’t evaluate in the query [duplicate]
- How do I make a redirect in PHP?
- List of All Locales and Their Short Codes?
- Whoops, looks like something went wrong. Laravel 5.0
- PHP “or” Syntax
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- How do I check if a string contains a specific word?
- Get the full URL in PHP
- How to copy a file from one directory to another using PHP?
- How can I find my php.ini on wordpress?
- PHP + curl, HTTP POST sample code?
- How to call a JavaScript function from PHP?
- Error 500: Premature end of script headers
- Cookies vs. sessions
- PDO with INSERT INTO through prepared statements
- How to get the file extension in PHP?
- Are there dictionaries in php?
- Multiple file upload in php
- laravel updateOrCreate method
- How to listen messageSent event in laravel 5.5
- When should I use ‘self’ over ‘$this’?
- php create object without class
- Creating a search form in PHP to search a database?
- How do I make a simple crawler in PHP?
- Create PDF file using PHP
- pdo – Call to a member function prepare() on a non-object
- Sort array of objects by object fields
- Compare given date with today
- When to generate a new Application Key in Laravel?
- “Connection for controluser as defined in your configuration failed” with phpMyAdmin in XAMPP
- Count how many files in directory PHP
- Simple PHP calculator
- What does it mean to escape a string?
- Convert from MySQL datetime to another format with PHP
- Creating default object from empty value in PHP?
- php foreach with multidimensional array
- header location not working in my php code
- PHP Error: Function name must be a string
- Uncaught Error: Call to undefined function mysql_escape_string()
- PHP cURL custom headers
- Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 201:
- How to convert string to boolean php
- PHP “&” operator
- Are There Any Cron Jobs Alternative?
- How to Create Multiple Where Clause Query Using Laravel Eloquent?
- PHP: How to get referrer URL?
- What is ?
- Connection reset by peer: mod_fcgid: error reading data from FastCGI server
- Warning: A non-numeric value encountered
- How to import csv file in PHP?
- What is the syntax for accessing PHP object properties?
- Proper Format of iframe in PHP?
- How to find the last day of the month from date?
- php_network_getaddresses: getaddrinfo failed: Name or service not known (0) Failed To Connect..!
- * failed to open vchiq instance
- Mysql where id is in array
- How to extract and access data from JSON with PHP?
- Warning “Do not Access Superglobal $_POST Array Directly” on Netbeans 7.4 for PHP
- How to get time difference in minutes in PHP
- How to write a link like which link to the same page in PHP?
- Call a REST API in PHP
- Fatal error: Call to a member function query() on null
- How can I write php code in notepad++?
- How to run a PHP function from an HTML form?
- How to insert TIMESTAMP into my MySQL table?
- Remove warning messages in PHP
- PHP date yesterday [duplicate]
- Clear cache in Symfony: `cache:clear` or `rm -rf`?
- create php live clock
- Converting a UNIX Timestamp to Formatted Date String
- PHP Call to undefined function
- Formatting a number with leading zeros in PHP
- Undefined index with $_POST [duplicate]
- file_get_contents() how to fix error “Failed to open stream”, “No such file”
- wordpress menu dropdown item not showing after first dropdown