douan7601 2014-05-04 17:31
浏览 41
已采纳

php / pdo INSERT函数不在phpmyadmin中显示字段内容

I'm trying to insert content from my form into my database. I'm using twitter bootstrap 3 to layout my website but here is the form;

<form class="form-horizontal" method="post" action="assets/mailreview.php" role="form">
<fieldset>

<!-- Form Name -->
<legend>Submit you're review</legend>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="firstname">First Name:</label>
  <div class="col-md-4">
  <input id="firstname" name="firstname" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="surname">Last Name:</label>
  <div class="col-md-4">
  <input id="surname" name="surname" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="email">Email:</label>
  <div class="col-md-4">
  <input id="email" name="email" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="title">Job Title:</label>
  <div class="col-md-4">
  <input id="title" name="title" placeholder="New kitchen.." class="form-control input-md" type="text">

  </div>
</div>

<!-- Textarea -->
<div class="form-group">
  <label class="col-md-4 control-label" for="brief">Description:</label>
  <div class="col-md-4">
    <textarea class="form-control" id="brief" name="brief">please type you're review here</textarea>
  </div>
</div>

<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label" for="submitbtn">Submit:</label>
  <div class="col-md-4">
    <button id="submitbtn" name="submitbtn" class="btn btn-primary">Submit</button>
  </div>
</div>

</fieldset>
</form>

As you can see I have set the submit action to respond to mailreview.php on doing so I receive no errors(after several and i mean several) however the form properties will not display in myphpadmin. It does insert a new row but not the field content.

here is mailreview.php

    <?php
    include_once("config.php");

$sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(:firstname,:lastname,:email,:title,:brief)";

$stmt = $db->prepare($sql);

$stmt->bindParam(':firstname', $_POST['firstname'], PDO::PARAM_STR);
$stmt->bindParam(':lastname', $_POST['surname'], PDO::PARAM_STR);
$stmt->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
$stmt->bindParam(':title', $_POST['title'], PDO::PARAM_STR);
$stmt->bindParam(':brief', $_POST['brief'], PDO::PARAM_STR);

$stmt->execute();

?>

any advice or support would be very grateful!!!

  • 写回答

2条回答 默认 最新

  • duan1933 2014-05-04 17:54
    关注

    You are missing colons on your list of values.

    Change this:

     $sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(firstname,lastname,email,title,brief)";
    

    to:

     $sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(:firstname,:lastname,:email,:title,:brief)";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。