dongyue8640 2019-02-19 19:46
浏览 67

为什么在使用PHP在MySQLi中运行multi_query之后显示所有记录不起作用但是单个查询呢?

Making a simple program of inserting multiple records in database and then showing whole table should probably have code like this:

Error Giving Code.

but is giving following error:

Error Given By above code

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统