php - mysqli fetch array error Couldn't fetch mysqli -


i trying input , display data on same page through mysqli but shows error "couldn't fetch mysqli on line" , not unable display records.

<?php  $db=mysqli_connect("localhost","root","","abc")  or die("not connected".mysqli_error()); $database=mysqli_select_db($db,'abc')  or die("database not found".mysqli_error());  if(isset($_post['submit'])){     $roll=$_post['roll'];     $name=$_post['name']; $ins=mysqli_query($db,"insert abc1 (roll,name)values('$roll','$name')"); } mysqli_close($db);  ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> </head>  <body> <form method="post"> roll no <input type="text" name="roll" /> name <input type="text" name="name" /> <input type="submit" name="submit" value="submit" /> </form> <table><tr> <td>roll no.</td> <td>name</td> </tr> <?php $query=mysqli_query($db,"select * abc1"); $result=mysqli_query($db,$query); $id=0; while($row=mysqli_fetch_array($result,mysqli_assoc)) { ?>  <tr><td><?php echo $row['roll']; ?></td> <td><?php echo $row['name']; ?></td> <?php } ?> </tr></table> </body>  </html> 

any appreciated. in advance

you doing mysqli_query twice. try this.

$query = "select * abc1"; $result = mysqli_query($db, $query);


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -