Error in php with database

can someone help me here to solve an issue in php for unidentifid variable used in database
code is given below

<div class="single">
	 <div class="container">
		  <div class="col-md-8 single-main">				 
			  <div class="single-grid">
					$id = $_GET['id'];
					$db = new Db();	
					$data = $db->view($id);
					while($rec = $data->fetch_object()){
					echo "<img src='Postimages/'".$rec->image."'.jpg' alt=''/>";
					echo "<h1>".$rec->title."</h1><br>";
					echo "<p>".$rec->article."</p>";
			 <ul class="comment-list">
					$db = new Db();
					$result = $db->admin();
					while($rec = $result->fetch_object()){
		  		   <h5 class="post-author_head">Written by <a href="#" title="Posts by admin" rel="author"><b><?php echo $rec->name;?></b></a></h5>
		  		   <li><img src="images/<?php $rec->image?>.png" class="img-responsive" alt="">	
		  		   <div class="desc">
		  		   <p>View all posts by: <a href="#" title="Posts by admin" rel="author"><?php echo $rec->name;?></a></p>
				   <?php }?>
		  		   <div class="clearfix"></div>
			  <div class="content-form">
					 <h3>Leave a comment</h3>
					<form action="comment.php" method="post">
						if(!(isset($_SESSION['admin']))){ ?>
						<input type="text" name="email" placeholder="Email" required/>
						<input type="text" name="pass" placeholder="Password" required/>
						<?php } ?>
						<input type="hidden" name="post_id" value="<?=$_GET['id']?>" required/>
						<textarea placeholder="Message" name="comment"></textarea>
						<input type="submit" name="send" value="SEND"/>
					$id = $_GET['id'];
					$view = $db->commentview($id);
					while($rec = $view->fetch_object()){
					$id = 8;
				   <div class="comment_sec">
						<div class="col-md-12">
							<img src="images/avatar.png">
							<a href="#"><h3><?$rec->name?></h3></a><p><?php $rec->created_on?></p>
							<h5><?php $rec->comment?></h5>	
				   <div class="clearfix"></div>

Please edit your post… so that the code is legible.

Also… what is the error message you are getting?

What variable is not being ‘identified’?

> <?php
>  $id = $_GET['id'];
>  $db = new Db();
>  $data = $db->view($id);
>  while($rec = $data->fetch_object()) {
>    echo "image."'.jpg' alt=''/>"; echo " # ".$rec->title." ";
>    echo "  ".$rec->article . " ";
>  }
> ?>

This first part of your code (formatted to be easier to read) shows that you are creating a new db().
What is that? You then use the newly created “db” object to access a view of it and then fetch data from
it. We need more info on what this “db” is. I would assume it is some sort of database connection, but,
you did not include a query.

Also, is this for a class project? If so, fill us in on what the class instructions are.

This line is going to break something

You don’t need to instantiate the Db class more than once, since they are the same class and you aren’t actually using two.

Need more specific info on the error, like what does it say, what variable is it complaining about?

Sponsor our Newsletter | Privacy Policy | Terms of Service