How to add MySQL to website and where to put PHP file?

Hi, i made website here and now i want to add database, but i have literally zero knowledge about backend. What should i do after creating table in phpmyadmin? I watched some videos on youtube but they don’t show how to actually make it work and they all use localhost, root etc. I tried to replace them with real data from my db, but it didn’t work. I don’t even understand where to put php file and where to look if it even works. It doesn’t work when i start my project with npm start like always. And how do i connect it to my project so i can fetch data from database somehow? I just need simple array of data with post and get functions. I have such data on my site from fake databases and they work good, but how to do it with my own real db? Please help. And sorry for my sucking ass english.

Those are a lot of questions, and many of them are not really suitable for a Q&A style format, and more of an in-depth tutorial or course.

In short, the guides you’ve read online are probably correct. You’ll just need to plug in the connection details (MySQL hostname, username, password, database name) and you can run your queries.

Please do note that our databases can only be accessed from code running on our servers, so you can’t test your PHP code (or Node.js) on your own computer with our database servers.

I think that this article may answer at least some of your questions:

Your website files should be uploaded to the htdocs folder of your account. You can upload them with the file manager or with an FTP client of your choice (like FileZilla).


Thanks you for answer, now i see why it didn’t work from my project folder. I have already website. Where should i put php file? Just drop it where my index.html is and it will somehow magically work?

Anywhere you want. Then to run it, just go to <yourDomain>/filename.php.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.