Urg, I will so happy when I'm finished this project, I feel like I'm spamming you guys every couple of days.

So I have a couple date values in my tables. And I'm trying to do some calculations with them. Which are working fine. But I'm retuning the number of days between two dates and I need to insert that into a table. The value in the table is an interger and I think this is why I'm getting a syntax error. My syntax is correct if I copy the query over to the console and replace the php variables with arbitrary values so I know it the query is structured correct at least.

$curDate = new DateTime();
$query = "SELECT * FROM checkout WHERE dueDate < CURDATE() and cardNumber = '$cardNumber'";
$result = mysql_query($query) or die(mysql_error());
if($lateBooks == 0){
	echo "There are no fines on this account";
if($lateBooks > 0){
		$finePerDay = 0.15;
		$dueDate = mysql_result($result, $i, "dueDate");
		$bookDue = new DateTime($dueDate);
		$libraryID = mysql_result($result, $i, "libraryID");
		$interval = $bookDue->diff($curDate);
		$daysLate = $interval->d;
		$fines = "INSERT INTO fines VALUES('$libraryID','$cardNumber','$daysLate'";
		$result = mysql_query($fines) or die(mysql_error());
		$fine = $daysLate * $finePerDay;

It craps out on the $fines query and I believe it has to do with the $daysLate variable not matching with the int(64) value it should be passed. I've tried casting $daysLate as an int but that doesn't seem to help.

6 Years
Discussion Span
Last Post by dyingatmidnight

It might be that that's not the problem, but there's a missing ) at the end of the query.
What does var_dump($daysLate); say?

Votes + Comments
nice spot

oh lololol. Clearly I have been looking at this stuff for far too long today to not have noticed that. Having added in the offending bracket it now works fine. Thanks so much.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.