How to setup MySQL for PHP on an already hosted website? - php

I hope you are doing well.
We have fully developed our website (this means everything, the domain, hosting, design is all done and the website is live and working). We chose Bluehost (bluehost.com) as our Hosting and Domain provider. Here's a snapshot of the panel I see (just in case for knowing the available menus) :
Now we have some PHP pages with us, and we need to integrate MySQL with it. I have seen some videos regarding this, but all of them were for localhost & XAAMP. I just need to know how to connect MySQL with a published website, so we can code the database storing section in our PHP file.
Can you suggest any tutorials/articles reffering this problem?
I hope you understand my query. Any help is appreciated!
Thanks 😀

First you must create a database then somewhere in the menu-settings the blue host gives you information about username and password , then modify your php database connection file with host(probably is localhost),username,password,and database name

Related

can't connect my old database to my new hostinger account

So, I had an old Hostinger account with all the information of my web page with some company that helped me with all of that, but we split and I created a new Hostinger account.
I tried everything to download the database I had in my old account, but nothing works, my WordPress now is disconnected, I tried to follow tutorials, uploaded my information whit FileZilla but nothing, my webpage is lost, I even uploaded mysql with php but it won't connect to the server!!
Please help!!!! What could I be doing wrong? I am so worried that I am gonna have to start over my web page, it took me a lot of time to finish it.
Thank you
This may be the wrong path on the server. You can try to install a clean WordPress on your site, and then transfer the whole site using this plugin or manually theme files, plugins, media using ftp manager and finally the database using this plugin.

System that can access database offline using PHP

Im currently developing a system using PHP and MySQL, what is required of the system is that it should allow the user be able to access the database on a standard GUI online (web browser) and should also be able to access the database offline, now can anyone help me with a method of how to make this possible.
The idea i have right now (me thinking out of the box) is using local host database manager like xampp which will be offline and an online database manager were the system will be hosted but cant figure out how will both databases be synchronized so that they stay the same.
If you want to have two databases maybe you will have to use a mirroring system. This one, wil help you to mantain the database syncronized with the database of the server with the local or not accessible database. You also can have a look at this link for more information Right way to mirror a PHP/MySQL setup

Connecting a website to a database

I am sorry if this is the wrong stack exchange, if so please redirect me.
I am very much in doubt about how I go about the following, and I can't really seem to google my way to a solution, so here goes:
Let's say I have a website which basically only consists of a search bar, which I want to link up to a database which every user can search in. In addition to this I want to be the only one who can actually add new data to this database.
To do this, would I basically "just" buy a website domain, make some SQL query hookup to a database that I rent from fx Microsoft Azure? Then whenever people would search for a string the website would query the database and return any relevant information.
Is this the correct way to go about this issue?
For your scenario, I would suggest you use Azure App Service MySQL in-app, which has a cool feature for Web developers to create Web applications that use MySQL. You don’t need to provision a database explicitly as during the creation of the web app when using this feature.
For more details, please refer to Announcing MySQL in-app for Web Apps and Create a PHP web app in Azure.

Is it safe to keep mysql login name and password in php page

I'm new to this so please be gentle with me!
I have a PHP login page which connects to a MYSQL table (users) for validation
I need a username and password to initially access the table. eg:
$con = mysqli_connect('localhost','masteruser','masteruserpassword,'users');
Is it safe to keep the username and password coded in the PHP file. I'm thinking it is because the PHP file will never be 'served' only executed.
Any tips please
PHP code is executed on server So no need to worry about this.
Only processed output from the php code is delivered to the client side in form of response in html and js.
It's totally safe. But it will be much better, if you move it to config file
It's safe unless somebody reach your server.
For what it's worth, WordPress works this way. The database access credentials are in plain text in a file called wp-config.php in the installation's root directory. WordPress is probably the most widely deployed MySQL based web app there is. So you should be OK. WordPress seems to be working fine. :-)
BUT: practice defense in depth. Create a special MySQL account for your web app, and restrict its privileges to the MySQL database (or databases) your web app needs. Don't put a MySQL administrative account in there.
Also, make sure that account is restricted so attempts to connect from machines other than your web host will fail.
Thirdly, try to use a MySQL server machine that's behind a firewall, and only accessible to other machines in the same data center.
Finally, keep routine backups.
If you're using a typical commercial shared hosting service they take care of most of this for you (maybe not the backups).
That way, if somebody does manage to crack your server and look at your password, they'll have a hard time making use of it, and if they do make use of it they won't be able to damage much. If they do damage your app, you'll be able to restore it from backup.

Can you change domain name without changing database wordpress?

I have a wordpress website that I used as my testing website. Now the client bought a hosting package that has no database. The idea now is to change the old URL of the testing site to a new domain name which the client bought. Can I transfer that new domain name to the old website and as well as change sub-pages but without a database? Please help me!!!!
Please!!!
I am not sure I understand the question.
Do you want to move the WP installation to a server without a DB? That won't work...
If you want to point the new domain to your server, go ahead and do that, afterwards change the domain settings in the WP admin. You might also have to change the wp-config, not 100% sure on that one.
But honestly, just tell your client that to buy a new server with the specs you give him. PHP version, DB etc. You are the expert not him.

Categories