Skip to content
Advertisement

NULL MAX(col) value even though DB has a valid record

So I am trying to extract the maximum invoiceNo for current year and this is how I implemented it with PDO:

However, $response keeps getting assigned to the else clause : enter image description here.

This is how my DB looks like: enter image description here

Hence I was expecting the $response to be 2022-2.

I think there is something wrong with my SQL query and I apologize for that, still learning the ropes!

Advertisement

Answer

Changed the way I named the variables in PHP and the placeholders in the SQL query. Thank you ADyson for all the help!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement