Skip to content
Advertisement

I can’t execute SQL sentence twice

I can’t execute SQL twice somehow.
In the case of below code, 1st SQL sentence【SELECT h.title, h.place, h.introduction ~】works. And 2nd one【SELECT name ~】 doesn’t work.

If I change 1st SQL sentence to comment out, 2nd SQL work correctly.

Do you notice how to work both of SQL.

JavaScript

As you can see, there are 3 SQL sentence in the code. I have no idea that the problem is in the SQL, HTML sentence or Datebase(phpMyAdmin).

Advertisement

Answer

You can’t use the same name for multiple queries.

Every name should be unique for multiple queries on the same page.

For example: $stmt for the first as it is, and for the second try a new name Like $stmt1 or $stmt_second, then it works perfectly.

For first query leave it as it is:

JavaScript

And for the second query change it to:

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