Making a simple program of inserting multiple records in database and then showing whole table should probably have code like this:
but is giving following error:
But, same code works when only one record is inserted and nothing else is changed.
<?php
$con=new mysqli("localhost","root","","lamkp");
if($con->connect_error)
die("error is: ".$con->connect_error);
else
echo "Connected!<br>";
/*
$ins="insert into teting values ('a');";
$ins.="insert into teting values ('b');";
$ins .="insert into teting values ('c');";
if ($con->multi_query($ins)===true) {
echo "Inserted all";
}*/
$ins="insert into teting values ('A word')";
if ($con->query($ins)===true) {
echo "Inserted word";
}
else
die("Error: ".$con->error);
$q="select * from teting";
echo "<table border=1>";
$run=$con->query($q);
if($run->num_rows>0){
while ($result=$run->fetch_assoc()) {
echo "<tr><td>".$result["name"]."</td></tr>";
}
}
else
die("Error: ".$con->error);
echo "</table>";
?>
Engine: InnoDB
What could be the cause of problem and solution of course?