mysqli - Unable to supply data from MYSQL on PHP -
okay having problems displaying text mysql database. file using display
<?php require('db_connect.php'); $sql = "select * cust_details"; $result = mysqli_query($con,$sql)or die(mysqli_error()); echo "<table>"; echo "<tr><td>date</td><td>comment</td><td>amount</td></tr>"; while($row = mysqli_fetch_array($result)) { $date = $row['name']; echo "<tr><td style='width: 200px;'>".$date."</td></tr>"; } echo "</table>"; mysqli_close($con); ?>
the db_connect.php file
<?php $con=mysqli_connect("my db host","my db username","my db pass","my db name"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } mysqli_close($con); ?>
here link phpmyadmin screenshot
http://postimg.org/image/afwlvb6gj/
as michael pointed out, closing connection in db_connect.php
. remove line containing mysqli_close($con);
looks following:
<?php $con=mysqli_connect("my db host","my db username","my db pass","my db name"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); }
php mysqli
No comments:
Post a Comment