database - Error: Column count doesn't match value count at row 1 -MySQL -
i beginner programmer , have started using mysql - using program called php myadmin create table in database. want enter in values , have values appear in table. have made table called table 1 in database called sweetshop. 2 rows put in php myadmin program called sweetid , sweetname. hope able help. sorry if don't come across clear - haven't been coding long!
the code i'm using particular section is:
<?php $con = mysqli_connect("localhost","root","","sweetshop"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: ".mysqli_connect_error(); } $result = mysqli_query($con,"select * table1"); echo "<table> <tr> <th>sweet id</th> <th>name</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo " <td>" . $row['sweetid'] . "</td>"; echo " <td>" . $row['sweetname'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?>
i assume mean columns have named sweetid , sweetname if so, change select statement from
$result = mysqli_query($con,"select * table1");
to
$result = mysqli_query($con,"select sweetid, sweetname sweetshop.table1");
and should (db name in select isn't required great habit develop now). try running exact select through phpmyadmin see result set looks well, if results there should them php
it helpful post full structure of table in case
Comments
Post a Comment