comment system jQuery/ajax php mysql -
im working on comment system don't know how fix bug.. when write text area , press submit, nothing happens. link file correctly! when dont enter textarea, shows given error.
here comment.php file
<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"> <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 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 * topmovies.comments order 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 } ?>
hope knows whats wrong! , maybe can give me tipps security/better performance etc.
your error can generated various causes, @ least code supposed have div
id
named flash
.
<div id='flash'>...</div>`
there aren't such div
on html parts.
Comments
Post a Comment