Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
注释系统jQuery/ajax php mysql_Php_Jquery_Mysql_Ajax_Comments - Fatal编程技术网

注释系统jQuery/ajax php mysql

注释系统jQuery/ajax php mysql,php,jquery,mysql,ajax,comments,Php,Jquery,Mysql,Ajax,Comments,我目前正在开发一个评论系统,但我不知道如何修复这个错误。。 当我在文本区域中写入内容并按submit时,什么也没有发生。 指向该文件的链接正确! 当我没有在文本区域中输入任何内容时,它会显示给定的错误 下面是comment.php文件 <script type="text/javascript"> function toggle_comment(id) { var e = document.getElementById(id); if(e.styl

我目前正在开发一个评论系统,但我不知道如何修复这个错误。。 当我在文本区域中写入内容并按submit时,什么也没有发生。 指向该文件的链接正确! 当我没有在文本区域中输入任何内容时,它会显示给定的错误

下面是comment.php文件

<script type="text/javascript">
    function toggle_comment(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }

    $(function() {

$(".submit").click(function() {

    var comment = $("#comment").val();
    var dataString = 'comment=' + comment;

    if(comment=='')
     {
    alert('Please Give Valide Details');
     }
    else
    {
    $("#flash").show();
    $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle">&nbsp;<span class="loading">Loading Comment...</span>');
$.ajax({
        type: "POST",
  url: "index.php?s=comment",
   data: dataString,
  cache: false,
  success: function(html){

  $("#flash").hide();

  }
 });
}
return false;
    });



});
</SCRIPT>


<a class="sitelinksblue" onclick="toggle_comment('commentfield');" style="font-family: Verdana, Geneva, sans-serif;font-size:12px;font-weight:bolder;">+ Kommentar abgeben für Englisch Für Anfänger</a>
<?php
if($_POST) {
$sqlCmd = "INSERT INTO topmovies.comments 
        (username,comment,date) 
        VALUES 
        ('".mysql_real_escape_string($_SESSION['user_username'])."','".mysql_real_escape_string($_POST["comment"])."','".$sqlZeit."')";
$sqlQry = mysql_query($sqlCmd,$sqlHp);
if (!$sqlQry) {
    die('Invalid query: ' . mysql_error());
}else { echo'Comment Added!';}
}
?>

<div id="commentfield" style="display:none">
    <form method="POST" action="#">
        <p>Dein Name: <?PHP echo $_SESSION['user_username']; ?></p>
        <textarea class="interfaceforms" name="comment" id="comment" rows="5" cols="20" maxlength="1555" value=""></textarea><br />
        <input type="submit" class="submit" value="Submit" />
    </form>
</div>
<?php
$sql=mysql_query("select * from topmovies.comments ORDER BY date DESC");
while($row=mysql_fetch_array($sql))
{
$username=$row['username'];
$comment=$row['comment'];
$date=$row['date'];
$name=$row['name'];
?>

<div id="comments" name="comments">
<div class="comments" style="padding-top:5px;">
        <BR>
    <table width="746px" style="display:inline;" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td rowspan="4" valign="top" width="154px" style="padding-right:19px;"><img style="display: block; padding-top:10px;" src="http://img.movie4k.to/img/user_top.gif" height="8px"/>
        <span class="test"><?php echo $username; ?><br />
        <br />
        <font size=1><?PHP echo date("d-m-Y", strtotime($date))?></br>
        <?PHP echo date("H:i", strtotime($date))?></font></span>
        <img style="display: block; background-color: #AFAFAF; padding-left:10px; padding-right:10px;" src="http://img.movie4k.to/userpics/476090.gif" width=40 height=50/>
        <img style="display: block;" src="http://img.movie4k.to/img/user_bottom.gif" height="8px"/></td>
        <td colspan="2" valign="bottom" height="8px"><img style="display: block; padding-top:10px;" src="http://img.movie4k.to/img/comment_top2.gif" height="8px"/></td>
        </tr>
        <tr>
        <td rowspan="2" width="522px" class="comment" valign="top" bgcolor="#E3E3E3" style="padding-left:10px; padding-right:17px;">
        <?php echo $comment; ?>
        </td>
        <td width="85px" valign="top" bgcolor="#E3E3E3" style="font-size:19px;">
        </td>
        </tr>
        <tr>
        <td bgcolor="#E3E3E3" valign="bottom"></td>
        </tr>
        <tr>
        <td colspan="2" valign="top" height="8px"><img style="display: block;" src="http://img.movie4k.to/img/comment_bottom2.gif" height="8px"/></td>
        </tr>
    </table>
</div>
</div>
<BR />
<?php
}
?>

函数切换注释(id){
var e=document.getElementById(id);
如果(e.style.display=='block')
e、 style.display='none';
其他的
e、 style.display='block';
}
$(函数(){
$(“.submit”)。单击(函数(){
var comment=$(“#comment”).val();
var dataString='comment='+comment;
如果(注释=“”)
{
警报(“请提供Valide详细信息”);
}
其他的
{
$(“#flash”).show();
$(“#flash”).fadeIn(400.html('loadingcomment…');
$.ajax({
类型:“POST”,
url:“index.php?s=comment”,
数据:dataString,
cache:false,
成功:函数(html){
$(“#flash”).hide();
}
});
}
返回false;
});
});
+康明塔尔·阿伯格本·弗林格(Kommentar abgeben für English für Anfänger)

您的错误可能由各种原因产生,但至少您的代码应该有一个名为
flash
div
,带有
id

 <div id='flash'>...</div>`
`

HTML部件上没有这样的
div

您的错误可能是由各种原因造成的,但至少您的代码应该有一个名为
flash
div

 <div id='flash'>...</div>`
`

HTML部件上没有此类
div

尝试将错误事件添加到ajax调用中,以便在ajax请求中出现错误时,它将显示错误。做一些类似于:

 $.ajax({
     type: "POST",
     url: "index.php?s=comment",
     data: dataString,
     cache: false,
     success: function(html){
         $("#flash").hide(); // no DOM found with id flash this is also the error 
     },
     error: function(e){
         alert("something wrong with ajax "+ e); // OR
         console.log(e)
     }
 });

尝试将错误事件添加到ajax调用中,这样,如果ajax请求中存在错误,那么它将显示错误。做一些类似于:

 $.ajax({
     type: "POST",
     url: "index.php?s=comment",
     data: dataString,
     cache: false,
     success: function(html){
         $("#flash").hide(); // no DOM found with id flash this is also the error 
     },
     error: function(e){
         alert("something wrong with ajax "+ e); // OR
         console.log(e)
     }
 });

稍微调试一下会有很大帮助,表单是通过ajax发布到脚本的吗?你确定什么都没有发生吗?你检查过你的控制台日志了吗?您没有在success上执行任何操作-
success:function(html){…//这里除了$(“#flash”).hide()}
稍微调试一下会有很大帮助,表单是否通过ajax发布到脚本中?您确定什么都没有发生吗?你检查过你的控制台日志了吗?您没有在success上执行任何操作-
success:function(html){…//除了$(“#flash”).hide()}