douxing1353 2015-01-18 16:50
浏览 54
已采纳

$ _POST没有插入数据库 - PHP MySQL

Here is my HTML form for adding data into the table:

<div class="TTWForm-container">
<div id="form-title" class="form-title field"><h2>ახალი სტატია</h2></div>
<form enctype="multipart/form-data" action="index.php?link=addart" class="TTWForm ui-sortable-disabled" method="post"> 
<div id="field2-container" class="field f_100 ui-resizable-disabled ui-state-disabled">
<label for="title">სათაური</label>
<input name="title" id="title" required="required" type="text">
</div>
<div id="field10-container" class="field f_100 ui-resizable-disabled ui-state-disabled">
<label for="post">
სტატია
</label>
<textarea rows="15" cols="40" name="post" id="post" required="required"></textarea>
</div>
<div id="form-submit" class="field f_100 clearfix submit">
<input value="დამატება" type="submit" id="submit">
</div>
</form>
</div>

processing

if (isset($_POST['title'])) {$title = $_POST['title'];}
if (isset($_POST['post'])) {$post = $_POST['post'];}

<?php
if (isset($title) && isset($post))
{
/*can add post */
$insert = "INSERT INTO article ('title','post') VALUES ('$title','$post')";
$result = mysqli_query($connect,$insert);

if ($result == 'true') {echo "<p>post is added.</p>";}
else {echo "<p>post is not added.</p>";}
}
else
{
echo "<p>Fill all fields.</p>";
}
?>

After processing it always says that post is not added. Checking database and its true. Cant find the mistake. Please help. Thanks.

  • 写回答

3条回答 默认 最新

  • duannuan0074 2015-01-18 16:56
    关注

    so just change:

    else
    {
    echo "<p>post is not added</p>";
    }
    

    to:

    else
    {
    echo "<p>MySQL error:".mysqli_error($connect)."</p>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥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 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)