I keep getting this error:
“Catchable fatal error: Object of class DateTime could not be converted to string”
From this code:
<?php
$value_startTime = new DateTime();
$value_startTime->setTime($value_HourStart,$_POST['TextBoxStartMin'],0);
$value_endTime = new DateTime();
$value_endTime->setTime($value_HourEnd,$_POST['TextBoxEndMin'],0);
$query_InsertJob="INSERT INTO job (jobDesc,timeStart,timeEnd)
VALUE ('$_POST[TextAreaProblem]','$value_startTime','$value_endTime')";
?>
These variables can have values from 00 to 23:
$value_HourStart
$value_HourEnd
These variables can have values from 00 to 59:
$_POST[‘TextBoxStartMin’]
$_POST[‘TextBoxEndMin’]
I am having no trouble with:
$_POST[TextAreaProblem]
What is it that I am doing wrong?
You need to convert those
DateTimeobjects into strings for use in the query.Try something like this (PDO example because I can’t abide encouraging people to use the
mysql_*functions)