So, if I understand the problem correctly, do you post a comment and do not paste into the database, and also presumably do not show the database error or print the Query failed line?
Does your PHP script seem to not run at all?
If so, I would say most likely the culprit of an intermittent error, such as your browser cache. Your browser looks at the URL, thinks it already knows what content comes with that URL, and returns that content without even sending information to the server. The easiest way to hack this is to add a random request to your file call, for example:
cachebuster = new Date(); '/ajax/comment.process.php?cachebuster='.cachebuster.getTime();
... I say "normal" since you are using POST and in "normal" circumstances the browser does not cache POST requests. But it’s possible, and it’s trivial to fight, so give him a chance. This can also be diagnosed if you use Chrome by pressing f12, go to the "network" tab, and then run your form. He should tell you if the result was obtained from the cache.
In addition, if you rely on magic_quotes (or, even worse, you do not rely on magic_quotes), you need to learn the right way to deal with SQL injection. You should never embed untrusted data from a browser directly into a database. Exit it or use parameterized queries. If you have a periodic problem with your request, it is probably related to the content of your comment, discarding the request under certain circumstances, as mentioned above, most likely, including the apostrophe in compression. Diagnose by sending two forms back: trythis , and then try'this . If the first goes, and the second fails, you most likely found your answer. Proper avoidance of input will help solve this problem.
Ultimately, all of these suggestions have already been given above, but hopefully this provides a little context to help understand why and where.
Edit: now I see that you are actually avoiding your request with a method that you have not used here. Assuming the job is correct, then this should not be a problem.
Try to repeat the valid answer at the beginning of your script without even executing anything. If this always returns, you at least know that the script call is successful.
There may be a problem with your working variable in case the ajax call is returned with an error. In such circumstances, it will never return false.
Your # 1 ally is the “Network” tab in Chrome’s Developer Tools or viewing the response on the console tab in the Firefox Firebug extension.
Edit 2:
$.post('/ajax/comment.process.php',$(this).serialize(),function(msg){