Fighting some lines of codes, that I copied because I didn't know how to write the fields from an object to MySQL. This used to work, but after changing the fields, the program now never come in the "If true" section anymore. When using printf($stmt) or print_r($stmt) in the false section, it returns an empty string.
Any help appreciated.
if ($stmt = $db->res->prepare("INSERT INTO rawdata( timestamp, NestName, NestUpdated, NestCurrentKelvin, "
. "NestTargetKelvin, NestTimeToTarget, NestHumidity, NestHeating, NestPostal_code, NestCountry, NestAutoAway, WeatherMain, "
. "WeatherDescription, WeatherTempKelvin, WeatherHumidity, WeatherTempMinKelvin, WeatherTempMaxKelvin, "
. "WeatherPressure, WeatherWindspeed, WeatherCityName) "
. "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"))
{
printf("
If true");
$stmt->bind_param('sssiiiisssiissiiiiiis',
$NestData['timestamp'],
$NestData['NestName'],
$NestData['NestUpdated' ],
$NestData['NestCurrentKelvin'],
$NestData['NestTargetKelvin'],
$NestData['NestTimeToTarget'],
$NestData['NestHumidity'],
$NestData['NestHeating'],
$NestData['NestPostal_code'],
$NestData['NestCountry'],
$NestData['NestAutoAway'],
$NestData['NestManualAway'],
$NestData['WeatherMain'],
$NestData['WeatherDescription'],
$NestData['WeatherTempKelvin'],
$NestData['WeatherHumidity'],
$NestData['WeatherTempMinKelvin'],
$NestData['WeatherTempMinKelvin'],
$NestData['WeatherPressure'],
$NestData['WeatherWindspeed'],
$NestData['WeatherCityName']
);
$stmt->execute();
printf("
%d Row inserted.
", $stmt->affected_rows);
if(mysqli_stmt_errno($stmt) > 0)
{
printf("Error Nr.
", mysqli_stmt_errno($stmt));
printf("Error
",mysqli_stmt_error($stmt));
$logRow = $logRow . "," . $stmt->affected_rows . "," . mysqli_stmt_error($stmt) . "
";
}
else
{
$logRow = $logRow . "," . $stmt->affected_rows . ",No Errors
";
}
$stmt->close();
}
else
{
printf("
If false");
print_r($stmt);
printf($stmt);
printf("
End false");
};
Any tips are welcome.