I am trying to find a way to auto-create a DB-entry by just visiting an url. The url is supposed to be visited once every new day.
This is my function that I am trying right now:
    function createMedOne() {
 $medid = "1";
 $mname = "Name1";
 $menh = "Amount 1";
 $mtime = "17:23";
 $mdte = date("Y-m-d");
 $mhtml = '<tr class="" id="med1">
        <td><p style="font-weight: bold;">Name1</p></td>
        <td>Amount 1</td>
        <td>Kl: 17:23</td>
        <td><button type="button" class="btn btn-warning btn-sm" style="float: right;">Sign</button></td>
      </tr>';
 $reg_med->addmed($medid,$mname,$menh,$mtime,$mdte,$mhtml);
}
createMedOne();
Other function:
function addmed($medid,$mname,$menh,$mtime,$mdte,$mhtml)
 {
  try
  {       
   $stmt = $this->conn->prepare("INSERT INTO tbl_med(medID,medName,medEnh,medTime,medDate,medHtml) 
                                                VALUES(:med_Id, :med_name, :med_enh, :med_time, :med_date, :med_html)");                                            
   $stmt->bindparam(":med_Id",$medid);      //id of the med
   $stmt->bindparam(":med_name",$mname);    //name of the med
   $stmt->bindparam(":med_enh",$menh);      //the amount
   $stmt->bindparam(":med_time",$mtime);    //When to give med
   $stmt->bindparam(":med_date",$mdte);     //date
   $stmt->bindparam(":med_html",$mhtml); //the html-code to generate content
   $stmt->execute(); 
   return $stmt;
  }
  catch(PDOException $ex)
  {
   echo $ex->getMessage();
  }
 }
When I visit the url I get the following error:
Fatal error: Call to a member function addmed() on null in test2.php on line 20
Which refers to the function createMedOne, but I can't find that I've missed something, but obviosly I have.
 
    