As the title states, within my files require_once is not working as intended.

I have a file where a user enters booking details and at the top it requires once the file to create the database and insert initial data into it.

The problem is it seems to be requiring it everytime, not just once.

For instance, i enter a booking and it goes into the database fine. When i revisit the booking page again, it requires that file again thus erasing the previous booking and adds the new booking. Ideally, the database should not be recreated and initialised again and there should be two new bookings rather than one.

I'm not sure why the require_once command is requiring the file more than once? Any Ideas?


It will be included just once for the duration of your script. Reloading the page restarts the script, thus including the file.

Is there any way i can get it to be included just once?

In the included file check whether the data (and database) exist and if not add records (otherwise do nothing). Or in your primary fle check whether the data exists and if not then include the file.