Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT</strong>:</p> <p>Ok good the screen shot means everything is getting submitted correctly to your php page. So then as we were suggesting the issue is with your SQL. Since the vote SQL seems to work fine its localized to insert youre trying to perform.</p> <p>If you could, can you post the sql schema for your "comments" table.</p> <p>also while youre doing thathave you tried runng the same query with a some test data directly form the commandline or a gui client to the sql server?</p> <p>for example from the commandline: mysql -u $USER -p $DATABASE INSERT INTO comments (comment,aid) VALUES ('i have something to say!', $AID);</p> <p>Where <code>$USER</code> is your username, and <code>$DATABASE</code> is your dbname... youll be prompted for the password for your user of course.</p> <p>Now im not sure what your schema looks like so if <code>aid</code> is a auto-increment you shouldnt be supplying a value, if its pk something arbitrary but unique for <code>$AID</code> (making sure it fits the column type - ie. int, text, varchar, etc..)</p> <p>post back your schema and whatever result the test query gives you.</p> <p><strong>EDIT</strong>:</p> <p>OK I want you to do this and then ammend your question with the output:</p> <p>use this code for submission (assuming #comment is still the id of the textarea:</p> <pre><code>$("#submit_js").click(function() { $.post( "user_submit.php", {comment: $("#comment").val()}, function(data){ alert(data); }); }); </code></pre> <p>Put this in your <code>user_submit.php</code> and comment out everything else:</p> <pre><code>print "Request Data is:\n"; print_r($_REQUEST); print "\n\nPost data is:\n"; print_r($_POST); </code></pre> <p>Post back what you see in the alert window that pops up.</p> <p><strong>EDIT:</strong></p> <blockquote> <p>i have posted the updated user_submit.php. this now even updates text in ajax. it is still unable to print the comment - amit</p> </blockquote> <p>I think i might know what it is... Exactly what type of element is <code>#comment</code>? Can you post the relevant HTML from your submission page?</p> <p><strong>EDIT:</strong></p> <p>I think youre confused about how ajax works. Youre assuming it works just like if you submit a form to a plain php page, then that page renders to the browser. This is not what happens. Instead you post to a page and you get a http response back, instead of rendering that response to the browser you get it as a javascript variable. Then you have to do something with that variable - like add it to the page somewhere. The problem is you havent done anything with the response youre getting back.</p> <p>Ok so...</p> <blockquote> <p>"@BranTheMan: then why isnt it echo'ing the text? and why isnt it adding anything to the DB? – amit"</p> </blockquote> <p>Its not echoing anythign in you page because youre not telling it to. What you seen in the firebug console is the response body. That doesnt go into your page with <code>$.post</code>. It jsut makes the call and give you the response. if you want to echo it in the current page then you need to tell it to do so.</p> <p>for example with the things you listed above:</p> <pre><code>$("#submit_js").click(function() { $.post( "user_submit.php", {comment: $("#comment").val()}, function(data){ $('#submit_js').append($('body', data).html()); }); }); </code></pre> <p>As for your SQL i dont know why its not adding properly... it looks fine. Have you checked your logs for any sql errors? Might want to through some error checking on the return from the query.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload