搜尋

首頁  >  問答  >  主體

留言板 出錯了 就是找不到錯誤在哪裡 頭痛

add.php檔案內容

<?php
//匯入連線資料庫檔案
include ('conn.php');
//偵測使用者是否提交按鈕
if(isset($_POST['submit'])){
         $id=$_POST['id'];
      1 $title=$_POST['title'];
         $content=$_POST['content'];
    $sql="insert into message(id,user,title,content,lastdate)value$sql="insert into message(id,user,title,content,lastdate)value$sql="insert into message(id,user,title,content,lastdate)value$sql' ,'$user','$title','$content',now())";
    mysqli_query($conn,$sql);
//    echo "<script>alert('新增成功');history.go(-1)</script>";
echo"<script>alert('留言成功');location.href='liu.html'</script>";
}else{
    echo "失敗";
}
?>


liu.html內容

#



    
        
        第一個 MYSQL 留言< ;<br/><script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-2.0.0.min.js"> ;</script> <br/><腳本類型=“text/javascript” src=“http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-ui”></script><br/><link href ="http://www.francescomalagrino.com/BootstrapPageGenerator/3/css/bootstrap-combined.min.css" rel="stylesheet" media="screen"><br/><腳本type="text/javascript " src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/bootstrap.min.js"></script><br/>         <?php include ("新增.php")?><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>############################################################################################## </head>###    <body>###        <?php include ("add.php")?>####        <divid="container -fluid">## ">###        <div class="span12">###            <div class="page-header">## #      與 1        第一篇MYSQL留言本<小>V1.0</小>###                </h1>###            </div>;<br/>            <div class="hero-unit"><br/>                <br/>                </h1><br/>               一個視覺化版面模板, 你可以點擊模板裡的文字進行修改, 也可以透過點擊彈出的編輯框進行豐富文本修改. 拖曳區塊能實現排序.<br/>                ;<br/>                    <a class="btn btn-primary btn-large" href="#">            </div><br/>            <table class="table table-bordered"><br/>                <thead                     <th><br/>                      </th> <br/>                        <th ><br/>                            名字<br/>                       <th><br/>                      與   lt;/th><br/>                        <th><br/>                        </th><br/> </tr><br/>                </thead><br/>             ="success"><br/>                        <td> <br/>                         </td><br/><td><br/>                            TB - 每月<br/>                         <td><br/>                              </td><br/>                        <已核准<br/>                        </td><br/>                </tbody> ;<br/>            </table><br/>            <form action="add.php" method=" post"><br/>                <fieldset><br/>                 <br/>                     <標籤>姓名</標籤><輸入類型=「文字」名稱=「使用者」必填/> <br/>                     <標籤>標題</標籤><輸入類型=「文字」名稱=「標題」必填/> <br/>                     <label>留言內容</label><textarea name="content" rows="5" cols="30"></text #  <button type="submit" class="btn" name="submith">提交</button><br/>                </fieldset>##  </div> <br/>    </div><br/></div><br/>    </body><br/></html><br/><br/><br/></p><p><br/></p><p><br/></p>##1; <p><br/></p><p><br/></p>  問題  :  沒錯提交感覺都沒走if  就到else了<p><br/></p>######</div><div class='info mb-10'><a rel="nofollow" href=" http://m.php.cn/zh-tw/member/107134.html"><img src='/static/images/user_avatar.jpg' alt="学海无涯"><span style="margin-left: 5px;">学海无涯</span></a><span class='pl-10'>2469 天前</span><span class='pl-10'>1250 <b class="kclbcollectb"></b></span></div></div><div class="course-list discuss layui-clear bg-white"><h3>全部回覆(8)<span class="detail_answer"><span id="discuss-wenda">我來回復</span></span></h3><li class="layui-clear"><div class="discuss-img"><img src="https://img.php.cn/upload/avatar/000/000/001/2cc6bbfa68cfcad12a6c0aa604e961a1.gif" alt="似火年华"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh-tw/member/4966.html" fid="" class="replyer-name">似火年华</a><span>2018-02-14 16:20:27</span></p><p class="content Overflow_line"><p>你確定你的sql語句沒有寫錯麼   $sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content' ,now())";</p><p>values(" 這裡錯了吧</p></p><span class="detail_answer2" style="float: left" fid="235231"><div class="btn wenda-second-btn" name="似火年华" fid="235231">回覆</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><li class="layui-clear"><div class="discuss-img"><img src="https://img.php.cn/upload/avatar/000/000/001/bba031d4b127c478e80130d026189e12.jpg" alt="Sven.He"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh-tw/member/113618.html" fid="" class="replyer-name">Sven.He</a><span>2018-02-12 12:48:15</span></p><p class="content Overflow_line"><p>你這樣寫一定會到else的。 不投稿 ,$_POST['submit'] 肯定沒有內容。 </p></p><span class="detail_answer2" style="float: left" fid="235221"><div class="btn wenda-second-btn" name="Sven.He" fid="235221">回覆</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><li class="layui-clear"><div class="discuss-img"><img src="https://img.php.cn/upload/avatar/000/000/002/61caddcba0718324.png" alt="PHP中文网"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh-tw/member/2.html" fid="" class="replyer-name">PHP中文网</a><span>2018-02-11 13:56:44</span></p><p class="content Overflow_line"><p>是新增失敗嗎? ? ? ?你看下  SQL語句    單引號是不解析變數的   其它的暫時沒能從程式碼上看出</p></p><span class="detail_answer2" style="float: left" fid="235214"><div class="btn wenda-second-btn" name="PHP中文网" fid="235214">回覆</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><li class="layui-clear"><div class="discuss-img"><img src="/static/images/user_avatar.jpg" alt="学海无涯"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh-tw/member/107134.html" fid="" class="replyer-name">学海无涯</a><span>2018-02-10 20:14:49</span></p><p class="content Overflow_line"><p>有大神幫忙看下麼<br/></p>#</p><span class="detail_answer2" style="float: left" fid="235197"><div class="btn wenda-second-btn" name="学海无涯" fid="235197">回覆</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><div class="reply-list"><div class="reply-item"><span class="pull-left comment-ops absolute"><span class="mr20"><a rel="nofollow" href="http://m.php.cn/zh-tw/member/122888.html" target="_blank"><img src="https://img.php.cn/upload/avatar/000/000/001/02a44f94f5000879ddcd02175a8e3c06.jpg" width="30" height="30" alt="徐金龙"></a></span></span><div class="reply-content-block"><div class="reply-content Overflow_line"><p>斷點列印是排查錯誤最有效的辦法之一</p></div><div><span class="comment-meta inline-block"><span> — </span><a rel="nofollow" target="_blank" class="reply_color" href="http://m.php.cn/zh-tw/member/122888.html"><strong>徐金龙</strong></a><span class="text-muted-plus"> · 2018-03-06 09:55:09</span></span></div></div></div></div><li class="layui-clear"><div class="discuss-img"><img src="https://img.php.cn/upload/avatar/000/013/745/5ad7f3132f63e720.jpg" alt="韦小宝"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh-tw/member/13745.html" fid="" class="replyer-name">韦小宝</a><span>2018-02-10 17:28:58</span></p><p class="content Overflow_line"><p>是直接就提示失敗了是麼? </p></p><span class="detail_answer2" style="float: left" fid="235194"><div class="btn wenda-second-btn" name="韦小宝" fid="235194">回覆</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><div class="reply-list"><div class="reply-item"><span class="pull-left comment-ops absolute"><span class="mr20"><a rel="nofollow" href="http://m.php.cn/zh-tw/member/107134.html" target="_blank"><img src="/static/images/user_avatar.jpg" width="30" height="30" alt="学海无涯"></a></span></span><div class="reply-content-block"><div class="reply-content Overflow_line"><p>是的 是的</p></div><div><span class="comment-meta inline-block"><span> — </span><a rel="nofollow" target="_blank" class="reply_color" href="http://m.php.cn/zh-tw/member/107134.html"><strong>学海无涯</strong></a><span class="text-muted-plus"> · 2018-02-10 18:00:28</span></span></div></div></div></div><div class="reply-list"><div class="reply-item"><span class="pull-left comment-ops absolute"><span class="mr20"><a rel="nofollow" href="http://m.php.cn/zh-tw/member/13745.html" target="_blank"><img src="https://img.php.cn/upload/avatar/000/013/745/5ad7f3132f63e720.jpg" width="30" height="30" alt="韦小宝"></a></span></span><div class="reply-content-block"><div class="reply-content Overflow_line"><p>你看看你獲取數據獲取到了麼</p></div><div><span class="comment-meta inline-block"><span> — </span><a rel="nofollow" target="_blank" class="reply_color" href="http://m.php.cn/zh-tw/member/13745.html"><strong>韦小宝</strong></a><span class="text-muted-plus"> · 2018-02-11 09:09:08</span></span></div></div></div></div><div class='more'></div></div><div class='discuss-submit bg-white'><li class='info layui-clear'><span class='f-left' id='discuss-submit-close'>取消</span><span class='f-left wenda-reply-text'>回覆</span></li><li class='layui-clear'><textarea type='text' rows="6" placeholder="請輸入您的評論內容" class="wenda-reply-content-text"></textarea></li><li class='layui-clear'><button class="layui-btn layui-btn-danger f-right wenda-reply-publish-button">發布</button></li></div><div class='lock-screen' id='lock-screen'></div><script src="/static/ueditor/third-party/SyntaxHighlighter/shCore.js"></script><div class="headerMask"></div><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>公益線上PHP培訓,幫助PHP學習者快速成長!</p></div><div class="footermid"><a href="http://m.php.cn/zh-tw/about/us.html">關於我們</a><a href="http://m.php.cn/zh-tw/about/disclaimer.html">免責聲明</a><a href="http://m.php.cn/zh-tw/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></body></html>