I have this undefined property error in code igniter : I have seen it run on other system. I couldnt sort it out plsease help.
Same issue is for the last_name. the update is giving issue. Below is the error it shows and then the whole code. Please help
Severity: Notice

Message: Undefined property: mysqli::$first_name

Filename: views/main_view.php

Line Number: 39

Backtrace:

File: C:\xampp\htdocs\test\application\views\main_view.php
Line: 39
Function: _error_handler

****This is the code****

        <!DOCTYPE html>
    <html>
    <head>
    	<title>View</title>
    	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    
    
    
    </head>
    <body>
    
    	
    <form method="post" action="<?php echo base_url("main/form_validation")?>">
    
    <?php
    
    if($this->uri->segment(2)=="inserted")
    {
    
    	echo '<p> Data Inserted</p>';
    }
    
    
    
      ?>
    
      <?php
    
    if(isset($user_data))
    {
    
    	foreach ($user_data as $row) 
    	{
    		?>
    		
    
    
    <div>
    First Name:<input type="text" name="first_name" value="<?php echo $row->first_name; ?>"/>
    <span class="text-danger"> <?php echo form_error("first_name");  ?></span> </br></br>
    </div>
    
    
      
    <div>
     Last Name:<input type="text" name="last_name" value="<?php echo $row->last_name; ?>">
     <span class="text-danger"> <?php echo form_error("last_name");  ?></span> </br></br>
    </div>
    <div>
    <input type="hidden" name="hidden_id" value="<?php echo $row->id; ?>" >
    <input type="submit"  name="update" value="Update" >
    
    </div>
    <?php
    
    
    }
    }else{
    
    
    
    
        ?>
    
    <div>
    First Name:<input type="text" name="first_name">
    <span class="text-danger"> <?php echo form_error("first_name");  ?></span> </br></br>
    </div>
    
    
      
    <div>
     Last Name:<input type="text" name="last_name">
     <span class="text-danger"> <?php echo form_error("last_name");  ?></span> </br></br>
    </div>
    
    
    
    <div>
    <input type="submit" name="hidde" value="Insert" >
    <input type="hidden"  name="insert" value="Insert" >
    
    </div>
    
    <?php 
    }  
    ?>
    </form>
    <br><br>
    
    <div>
    <table>
    	<tr>
    		<th>ID</th>
    		<th> First Name</th>
    		<th> Last Name </th>
    		<th> Delete </th>
    		<th> Update </th>
    
    
    
    	</tr>
    
    	<?php 
    
    	if($fetch_data->num_rows()>0)
    	{
    		foreach ($fetch_data->result() as $row ) {
    			?>
    			<tr>
    				<td><?php echo $row->id;  ?> </td>
    				<td><?php echo $row->first_name;  ?> </td>
    				<td><?php echo $row->last_name;  ?> </td>
    				<td> <a href="#" class="delete_data" id="<?php echo $row->id;  ?>"> Delete </a></td>
    				<td> <a href=" <?php echo base_url(); ?>main/update_data/ <?php echo $row->id; ?>"> Edit  </a></td>
    
    
    
    			</tr>
    
    
    			<?php 
    		}
    
    
    	}else{
    		?>
    
    		<tr>
    			<th colspan="4">
    				No data Found
    			</th>
    
    		</tr>
    
    
    	<?php
    	}
    
    
    	 ?>
    
    
    
    </table>
    </div>
    
    <script type="text/javascript">
    	
    
    $(document).ready(function(){
    
    	$('.delete_data').click(function(){
    
    		var id = $(this).attr("id");
    		if(confirm("Delete? or not?"))
    		{
    			window.location="<?php echo base_url(); ?>main/delete_data/"+id;
    
    		}else{
    			return false;
    
    
    		}
    	});
    });
    
    </script>
    
    
    
    </body>
    </html>