php - My website started to load slow after I added mysqli


I am sorry if there is lack of information I'm not that really good of explaining and English is not my native language.

After I designed the website withhtml/css etc...I started to addmysqli, to display the user information, tables.




I just glimmsed at your code: In every function, you are callingdb_login(), which opens every time a new database connection. Try to reuse the same database connection, would speed up a lot.

For example you can make a global variable, where you open the connection once and then import the variable via the global keyword, or you could pass the functions this variable as parameter. This best option though, would be designing the whole thing into a class, where the (open) connection is a shared variable of the instance of this class.

People are also looking for solutions to the problem: php - calculate math expression from a string using eval


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.