In My code i am using a prepare statement using bind_result. In the following code i access all values on the carmake table. In that when I am going to access the admin name it gives me the error "Call to a member function bind_param() on a non-object". I have used this code previously. i used get_result at that time and it worked fine, but when I used bind_result it gives an error
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
</script>
<?php
session_start();
if(isset($_SESSION['username1']))
{
include("../config/database.php");
if(isset($_GET["page"]))
{
$page = $_GET["page"];
$rows_per_page = 10;
}
else
{
$page=1;
}
$start_from = ($page * 10) -10;
$limit = ($page * 10);
$query=$conn->prepare("SELECT makeid,name,status,creation_date_and_time,created_by FROM carmake ORDER BY makeid desc LIMIT $start_from,10");
$query->execute();
$query->bind_result($makeid,$name,$status,$creation_date_and_time,$created_by);
//$result=$query->get_result();
?>
<?php
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
<tr>
<th width="6%" align="center" class="tbl_back"> Id</th>
<th width="12%" align="center" class="tbl_back">Name</th>
<th width="12%" align="center" class="tbl_back">Created by</th>
<th width="12%" align="center" class="tbl_back">Status</th>
<th width="12%" align="center" class="tbl_back">Edit</th>
<th width="12%" align="center" class="tbl_back">Delete</th>
</tr>
<?php
//$i = 0;
while($query->fetch())
{
/* Construct Data */
?>
<?php
/*$serviceid=$data['servicetype'];
$query2="select * FROM tblservicemaster where serviceid='$serviceid'";
$result2 = mysql_query($query2,$conn) or die(mysql_error());
$leadservice=mysql_fetch_array($result2);*/
?>
<tr>
<td class="tbl_back1"><?php echo $makeid ?></td>
<td class="tbl_back1"><?php echo $name ?></td>
<td class="tbl_back1"> <?php
$idd=$created_by;
$query1=$conn->prepare("select name,adminid from admintable where adminid=?");
$query1->bind_param("i",$idd);
$query1->execute();
$query1->bind_result($name,$adminid);
//$query1->store_result();
$query1->fetch();
/* $query1="select name from admintable where id=".$data[4];
$result1=mysql_query($query1) or die(mysql_error());
$data1=mysql_fetch_array($result1);*/
echo $name;
?> </td>
<td class="tbl_back1"><?php if($status==1){echo "Enabled";}if($status==0){echo "Disabled";} ?></td>
<td class="celledit"><a href="edit_carmakepages.php?id=<?php echo $makeid; ?>"><center><img src="images/editsign.jpg"/></center> </a></td>
<td class="celldelete"><a href="javascript:del_topic(<?php echo makeid; ?>)"><center><img src="images/deletesign.jpg"/></center> </a></td>
<?php
//$i++;
?>
</tr>
</tr>
<?php
} // end while
/*else
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
<tr>
<th width="6%" align="center" class="tbl_back"> Id</th>
<th width="12%" align="center" class="tbl_back">Name</th>
<th width="12%" align="center" class="tbl_back">Created by</th>
<th width="12%" align="center" class="tbl_back">Status</th>
<th width="12%" align="center" class="tbl_back">Edit</th>
<th width="12%" align="center" class="tbl_back">Delete</th>
</tr>
<tr>
<td colspan="15" align="center" style=" color:red" class="tbl_back12">
No Record Found
<!--<h4 class="aligncenter">No Record Found</h4>-->
</td>
</tr>
<?php
}*/
?>
</tbody>
</table>
<?php } ?>
</html>