unable to insert xml string into mysql table



i want to insert below xml string into mysql database



<message to='". $groupMembersArray[$i] . "@crossmessenger.com' type='groupchat' from='$mFrom'><x xmlns='jabber:x:event'><offline/><delivered/><displayed/></x><body>$message</body></message>


so for that i have written below code



$message="sdfsd";
$creationDate = $httpBody->creationTime;
$messageID = $httpBody->messageID;
$stanzaToInsert = "<message to='". $groupMembersArray[$i] . "@crossmessenger.com' type='groupchat' from='$mFrom'><x xmlns='jabber:x:event'><offline/><delivered/><displayed/></x><body>$message</body></message>";
$msgSize = strlen($stanzaToInsert);
$insertQuery = "INSERT INTO ofOffline VALUES ($groupMembersArray[$i], $messageID, $creationDate, $msgSize, '$stanzaToInsert')";
mysqli_query($connection, $insertQuery);
mysqli_commit($connection);


but nothing is inserting in database. if i replace xml string that means value of stanzaToInsert to some simple text, then it is inserting value into database.



$insertQuery = "INSERT INTO ofOffline VALUES ($groupMembersArray[$i], $messageID, $creationDate, $msgSize, 'hard coded string')";


so problem is with xml string.


so can i know "what wrong i am doing"?


No comments:

Post a Comment