Hi. I am tring to setup a basic HTTP connection between my game and localhost. The connection is working fine. But, I am receiving null at the database.
Here is the code chunk being used:
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
Request->SetURL(TEXT("http://127.0.0.1/insertGameStats.php"));
Request->SetVerb(TEXT("POST"));
Request->SetContentAsString(CurrentRequest.TheData);
Request->OnProcessRequestComplete().BindUObject(this, &AHTTPHandlerActor::OnResponseReceived);
Here is how I set data:
CurrentRequest.AddURLPair(param, value);
void AddURLPair(FString param, FString value)
{
TheData += (delim + param + "=" + value);
delim = "&";
}
The php Script:
$con = mysql_connect($db_hostname,$db_username);
if(!$con)
{
die("Unable to Connect to MySQL: " . mysql_error());
}
$val = $_POST’val’];
mysql_select_db($db_database, $con);
$sql = “INSERT INTO testtable(value)
VALUES
(’$val’)”;
if(!mysql_query($sql, $con))
{
die('Error: ’ . mysql_error());
}
echo “1 record added to the game stats database”;
mysql_close($con);
I know that the connection is being established, because a new entry is being made in the table. But, it is all NULL.
Any help would be greatly appreciated