string myParameters = "serial=" + serial + "&command_id=" + cmd_id + "&successfullyExecuted=1&command_type=" + getCommandType(cmd) + "&answer=" + executeCommand(cmd);
using (WebClient wc22 = new WebClient())
{
wc22.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = wc22.UploadString(URI, myParameters);
}
The getCommand(cmd) returns a very long string (about 1.70 MBytes). When I write it to a text file using File.WriteAllText("debug.txt"); I can see all the data. However, in my database, I see only a part of it. It is truncated.
My sql column type is "LONG TEXT"
Edit (result is holding what is going to be returned by executeCommand() ):
StringWriter stringw = new StringWriter();
Console.SetOut(stringw);
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
DirSearch(d.Name, commandContent);
}
result = stringw.ToString();
File.WriteAllText("debug.txt", result); // <-- This file contains full data
Database is MySQL and I'm looking at the data directly using phpMyAdmin
And here is the page I'm posting to :
<?php
if (isset($_POST['serial'])) {
//Include the database connection file
include "database_connection.php";
// prevent sql injection
$serial = mysql_real_escape_string(($_POST['serial']));
if (isset($_POST['successfullyExecuted'],$_POST['command_id'],$_POST['command_type'],$_POST['answer'])) {
$cmdID = mysql_real_escape_string($_POST['command_id']);
$cmdType = mysql_real_escape_string($_POST['command_type']);
$answer = mysql_real_escape_string($_POST['answer']);
$executeSuccess = mysql_real_escape_string($_POST['successfullyExecuted']);
if ("1" == $executeSuccess) {
// TRUE : Command executed successfully
$q = "UPDATE `eu181976_kl`.`commands` SET `whether_executed` = 1,`answer_type` = '".$cmdType."',`answer` = '".$answer."' WHERE `commands`.`to_whom` = '".mysql_real_escape_string($serial)."' AND `commands`.`id` = '".mysql_real_escape_string($cmdID)."' ;";
$updateNow = mysql_query($q);
} else if ("0" == $executeSuccess) {
// FALSE : There was an error executing the command
$q = "UPDATE `eu181976_kl`.`commands` SET `whether_active` = 0,`answer_type` = '".$cmdType."' WHERE `commands`.`to_whom` = '".mysql_real_escape_string($serial)."' AND `commands`.`id` = '".mysql_real_escape_string($cmdID)."' ;";
$updateNow = mysql_query($q);
} else {
// There was an error in the link
echo "There was an error in query";
}
} else {
//Check the database table for the logged in user information
$q = "SELECT * FROM commands WHERE to_whom='".$serial."' AND whether_executed=0 AND whether_active=1 LIMIT 1";
$ros=mysql_query($q);
if (!mysql_num_rows($ros) > 0) {
echo 'NULL';
} else {
while($row=mysql_fetch_array($ros))
{
echo $row['id'].':'.$row['cmd_text'];
}
}
}
}
?>
EDIT: I'm not sure whether (&) could be the reason but the text is truncated there, whatever after that character is not inserted :