I need to migrate my code from mysql to mysqli. I am new with coding so probably the mistake I am doing is really silly but please help me.
<?php
$host="localhost"; // Host name
$db_username="koko_login"; // Mysql username
$db_password="YES"; // Mysql password
$db_name="koko_database"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
// mysql_connect("$host", "$db_username", "$db_password")or die("cannot connect");
// mysql_select_db("$db_name")or die("cannot select DB");
$connection = mysqli_connect( 'host', 'username', 'password');
$database = mysqli_select_db($link, 'database');
if (isset($_SESSION['username'])){
$username = $_SESSION['username'];
$password = $_SESSION['username'];
}
function generate_event_link($tbl_name, $username, $key)
{
$sql="SELECT * FROM $tbl_name WHERE username='$username'";
$result=mysqli_query( $link, $query);
$count=mysqli_num_rows( $result);
$arr = mysqli_fetch_array( $result, $type);
if ($arr[$key] != 0){
$href= "http://localhost/koko/event_page.php?id=" . $arr[$key]; ?>
<li class="divider"></li>
<li><a href=<? echo $href ?>"#">Your Event<img class="img responsive pull-right" src="icons/house.png" alt="User"></a></li>
<?}}
?>