SQL插入表不起作用

时间:2012-04-01 09:37:21

标签: php html

我正在尝试将状态更新插入到名为blabbing的表中的数据库中,但它无效。

我的PHP代码

$thisRandNum = rand(9999999999999,999999999999999999);
$_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs

// ------- POST NEW BLAB TO DATABASE ---------
$blab_outout_msg = "";
if (isset($_POST['status']) && $_POST['status'] != "" && $_POST['status'] != " "){

     $blabWipit = $_POST['blabWipit'];
     $sessWipit = base64_decode($_SESSION['wipit']);
     if (!isset($_SESSION['wipit'])) {

     } else if ($blabWipit == $sessWipit) {

          // End Delete any blabs over 20 for this member
         $status = $_POST['status'];
         $status = stripslashes($status);
         $status = strip_tags($status);
         $status = mysql_real_escape_string($status);
         $status = str_replace("'", "'", $status);
         $sql = mysql_query("INSERT INTO blabbing (mem_id, profile_id, the_blab, blab_date) VALUES('$logOptions_id','$logOptions_id','$status', now())");
         $blab_outout_msg = "";
         }

}

我的HTML代码

<div style="background-color:#f2f2f2; border:#ebebeb 1px solid; padding:8px;">
    <form action="home.php" method="post" enctype="multipart/form-data" name="blab_from">
    <textarea name="status" id="status" rows="3" style="width:99%;"></textarea>
    <input name="submit" type="submit" class="btn" value="Blab" /> &nbsp; &nbsp; Limit:  <script>displaylimit("","status",255)</script>
     <input name="blabWipit" type="hidden" value="<? print $thisRandNum;?>" />
    </form>
    </div>

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:1)

$thisRandNum = rand(9999999999999,999999999999999999);
$_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs

// ------- POST NEW BLAB TO DATABASE ---------
$blab_outout_msg = "";
if (isset($_POST['status']) && $_POST['status'] != "" && $_POST['status'] != " "){

     $blabWipit = $_POST['blabWipit'];
     $sessWipit = base64_decode($_SESSION['wipit']);
    // if (!isset($_SESSION['wipit'])) {

     //} else if ($blabWipit == $sessWipit) {

          // End Delete any blabs over 20 for this member
         $status = $_POST['status'];
         $status = stripslashes($status);
         $status = strip_tags($status);
         $status = mysql_real_escape_string($status);
         $status = str_replace("'", "&#39;", $status);
         $sql = mysql_query("INSERT INTO blabbing (mem_id, profile_id, the_blab, blab_date) VALUES('$logOptions_id','$logOptions_id','$status', now())");
         $blab_outout_msg = "";
       //  }

}

尝试此操作如果有效则else if ($blabWipit == $sessWipit) {此条件不正确