This question already has an answer here:
i have this error: "Parse error: syntax error, unexpected T_LNUMBER in line 14 " i would like to calculate difference between two dates
function datedifference()
{
$res=dbconnect()->exec("SELECT DATEDIFF("2017-06-25", "2017-06-15");");
echo $res;
}
</div>
The problem is that your string syntax is wrong, you have not escaped the "
quotes inside the string, you can either use '
single-quote or escape the double quote:
Single-quote:
$res = dbconnect()->exec("SELECT DATEDIFF('2017-06-25', '2017-06-15');");
Escaped double quote:
$res = dbconnect()->exec("SELECT DATEDIFF(\"2017-06-25\", \"2017-06-15\");");