Warning: mysqli_select_db() expects parameter 1 to be mysqli,

FULL ERROR: ( ! ) Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp64\www\link.php on line 4

Hello guys I have recently started learning PHP and I have bumped into this erorr that is listed above. I can’t seem to fix it AT ALL! If anyone has a fix for it please list it below! Thanks!
Here is my code:

[php]<?php
@include_once ‘settings.php’;
//session_start
$link = mysqli_connect($servername, $username, $password); //MySQL Host, Username, password
$db_selected = mysqli_select_db(‘database’, $link); //MySql database
mysqli_query(“SET NAMES utf8”);

function fetchinfo($rowname, $tablename, $finder, $findervalue)
{
if ($finder == “1”)
$result = mysqli_query(“SELECT $rowname FROM $tablename”);
else
$result = mysqli_query(“SELECT $rowname FROM $tablename WHERE $finder =$findervalue”);
$row = mysqli_fetch_assoc($result);
return $row[$rowname];
}

function secureoutput($string)
{
$string = mysqli_real_escape_string($string);
$string = htmlentities(strip_tags($string));
$string = str_replace(’>’, ‘’, $string);
$string = str_replace(’<’, ‘’, $string);
$string = htmlspecialchars($string);
return $string;
}
?>[/php]

You have the order incorrect.

If you are just starting PHP, don’t abstract the SQL, when you don’t understand what you are actually doing. Use prepared statements and not the “mysqli_real_escape_string” crap.

OP was already given the answer on another forum.

Sponsor our Newsletter | Privacy Policy | Terms of Service