Skip to content
Advertisement

php stop sql query from running every time on refresh

In my php script, I used a sql query to create a table, but after creating the table every subsequent refresh will return an error message stating table is already created. I know its already created but how do I stop query from running a second time on refresh if its already ran?

php script:

Advertisement

Answer

The DDL commands, such as create table, should be in a separate file which is called only one time in the initialization step. This is the formal way to be away from errors.

Another way that may help, but not efficient, is by using: CREATE TABLE IF NOT EXISTS Students2(....).

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