title: Deprecated mysql_query and mysql_connect - code update
body: <p>Years ago a friend of mine wrote a piece of code for me to do some simple function of recording a learning progress for my joomla site users. Now that I have updated the Joomla to 3.6 on PHP7, the site is reporting deprecated queries which did not surprise me. I tried to replace the queries with mysqli but I have failed to make the function work. Would someone take a look for me? Thank you so much.</p>
  
  <pre><code>&lt;?php
  /*      $host = "localhost";
  $user = "administrator"; 
  $pass = "web-Test";//enter here your sql password
  $db_name = "e-learning";
  $link = mysql_connect($host, $user,$pass);
  mysql_select_db($db_name, $link)or die("unable to select database");  */
  include'const.php';
  $link = mysql_connect($host, $user,$pass);
  if (!$link) {
  echo('Could not connect');
  }
  else {
  mysql_select_db($db, $link) or die("can not select database").mysql_error();    
  }   
  $ip=getenv('REMOTE_ADDR');  
  //$new_array_without_nulls = array_filter($_POST, 'strlen');
  
  if($_POST)
  {
  
  // --------comment
  $uid = $_POST['uid'];
  unset($_POST['uid']);
  $cmt = array();
  foreach($_POST as $key =&gt; $value)
      {
          if ($value != 'true' &amp;&amp; $value != 'Progress' &amp;&amp; $value != 'false')
          {
              $cmt[$key] = $value;
          }
      }
  foreach ($cmt as $key =&gt; $value)
  $cmt_value = implode(',' , $cmt);
  // --------Check 
  $check = array();
  foreach($_POST as $key =&gt; $value)
      {
          if ($value == 'true')
          {
              $check[$key] = $value;
          }
      }
  //finding key
  $check_key = array();
  foreach ($check as $key =&gt; $value){
      array_push($check_key,$key);
  }
  foreach ($check_key as $key =&gt; $value)
  $check_value = implode(',' , $check_key);   
  
  //$uid = $user-&gt;get('id');
  $content_name = $_POST['contentname'];
  function CheckExistContentName($content_name,$uid){
      $name_exist = mysql_query("select * from Progress where content_name = '$content_name' and User_id = $uid ");
      $arr = array();
      while($row = mysql_fetch_array($name_exist))
      {
      $arr = $row;
      }
      return $arr;
  }
  if(CheckExistContentName($content_name,$uid))
  {
      $sql = "update Progress set User_id = '".$uid."', ip = '".$ip."',content_name = '".$content_name."',arr_check = '".$check_value."',arr_cmt = '".$cmt_value."' where content_name = '$content_name' and User_id = $uid";
      $rs_result = mysql_query($sql);
      echo "&lt;h2&gt; Your learning progress has been updated &lt;/h2&gt;";
  }
  else 
  {
      $sql = "insert into Progress(User_id,ip,content_name,arr_check,arr_cmt) values ('".$uid."','".$ip."','".$content_name."','".$check_value."','".$cmt_value."')";
      $rs_result = mysql_query($sql);
      echo "&lt;h2&gt; Your learning progress has been saved &lt;/h2&gt;";
  }
  }
  //}
  ?&gt;
  </code></pre>