WordPress mySQL Query in PHP - Trouble connecting to database

php
phpmyadmin
wordpress
mysql

#1

Hi.

I need help please. I am all very new to this and trying to do something way out of my comfort zone/knowledge/experience…

I am trying to query the SQL database under the C9 directory called wp_hcr_car_booking

I’m not sure how to declare $connection so that this part of my code works:

Any ideas would be very appreciated, I’m mostly figuring this out from google and I seem to be missing something vital. The weird thing is that the code further down that inserts the form data into the table is actually working (possibly because I’m not getting a result) and my if statement halts if there is.

The next step after this is to prevent double bookings based on start and end time and the date but that’s a problem for when this is solved.