error in json function saving data into database

I have tried a lot but I have not been able to find out what is wrong with this function to save two values into database. It has been working fine for another function to save one value. It behaves very strange here. Sometimes send 'parent' value & sometimes stop sending it but never send msg value. Here is function. It works fine for one input i.e. parent but problems start with the addition of 2nd input.

function ADDLISITEM(form)
var parent = form.txtInput.value;
    var msg    = form.msgInput.value;
    form.txtInput.value = "";
    form.msgInput.value = "";
    var url = "send_mysql.php"
var request = null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
request=new XMLHttpRequest();
{// code for IE6, IE5
request=new ActiveXObject("Microsoft.XMLHTTP");
}"POST", url, true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.setRequestHeader("Connection", "close");
request.onreadystatechange = function(){
    if (request.readyState == 4) {
        if (request.status == 200) {
    } else {
        alert(request.status); // fails here
request.send("parent=" + encodeURIComponent(parent).replace(/%20/g, '+')+"&msg=" + 
    encodeURIComponent(msg).replace(/%20/g, '+'));

This is send.php

$username = "babar"; $password = "k4541616"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("spec",$dbh) or die("Could not select first_test");


  $parent = $_POST['parent'];
  $msg = $_POST['msg'];
  $name   = 'Akhtar Nutt';
  //$parent2 = json_decode($parent);
  $msg_ID = '2q7b2sfwwe';
  //$msg2    = json_decode($msg);
  $query  =  "INSERT INTO msg2_Qualities(id,name,msg,msg_id,parent) VALUES  
    if(!mysql_query($query, $dbh))
        {die('error:' .mysql_error())




request.send("parent=" + encodeURIComponent(parent).replace(/%20/g, '+')+"msg=" + encodeURIComponent(msg).replace(/%20/g, '+'));


request.send("parent=" + encodeURIComponent(parent).replace(/%20/g, '+')+"&msg=" + encodeURIComponent(msg).replace(/%20/g, '+'));

You're missing the argument separator & in your query string...

You also might want to refrain from using values in $_REQUEST as they aren't reliable. If your script expects data from a POST then retrieve these values from $_POST.

Need Your Help

Why doesn't Java include the time/space complexity of each function in the javadoc?

java string complexity-theory javadoc replaceall

Hi I want to know what is the time complexity of the "replaceAll" function of the String class but I can't find any information on it.(

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.