Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6387005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:05:53+00:00 2026-05-25T03:05:53+00:00

I’m writing a fairly basic commenting function for a site using post method to

  • 0

I’m writing a fairly basic commenting function for a site using post method to pass input values to a php file that performs the relevant mysql query.

The $.ajax part is as follows:

// AJAX URL ENCODING
$("#add").click(function() {  
        // POST COMMENT FORM VALUES
        var ajaxOpts = {  
        type: "post",  
        url: "includes/addComment.php",  
        data: "&author=" + $("#author").find("input").val() + "&email=" + $("#email").find("input").val() + "&comment=" + $("#leaveComment").find("textarea").val() + "&parent=<?php echo $vid_id; ?>",  
        success: function(data) {  

            // IMMEDIATE DISPLAY
            // Not relevant to this problem.

            // CLEAR TEXTAREA FOR NEXT COMMENT
            $("textarea").val('');  
        } 


        };  

    $.ajax(ajaxOpts);  
});

This is passed through to addcomment.php:

require('connection.php');    

//get POST data  
$name = mysql_real_escape_string($_POST["author"]); 
$email = strtolower(md5(trim(mysql_real_escape_string($_POST["email"])))); 
$comment = mysql_real_escape_string($_POST["comment"]);
$time = Date ('c');
$parent = trim(mysql_real_escape_string($_POST["parent"]));


//add new comment to database  
mysql_query("INSERT INTO comments VALUES(' $name ',' $email ',' $comment ', ' $time ', ' $parent ')"); 

Everything works fine except that the mysql_query doesn’t end up inserting any values into my database. After a bit of digging I found this:

screen grab

So i’m assuming my query isn’t going ahead because the ‘ : ‘ bit of junk(?) data is throwing everything out?

I’m trying to figure out where this errant ‘ : ‘ has come from, anyone have any ideas?

P.S – Apologies for the length of this question, I’ve tried to narrow down possible culprits as much as I can.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:05:54+00:00Added an answer on May 25, 2026 at 3:05 am

    what happens if you remove the & from the front of &author?

    normally the first data field doesn’t have an &

    data: "&author=" 
    

    also as others have mentioned this would be a welcome addition

    or die (mysql_error()) 
    

    and its usually good practice to name your database columns on the insert
    otherwise you risk breaking the insert statement if you ever alter the table structure

    insert into (colname1, colname2) values ('value1', 'value2')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.