0

Quite an amature question here, but Google can't give me answers.

I am setting up apache on my computer to contain my php and html files. The purpose of this is I wish to be able to use mariadb to store information in which the php files can communicate with this db for my website.

Previously I could have php files on a paid web server and query my mysql database through there as it was straightforward and mysql was easy to use through their control panel.

My question is, how will my php files, residing in the htdocs folder, query the Maria database I have installed on my computer. What even is the process for this to happen?

Tia.

  • PHP as specific API to connect to the databases. MYSQLI_* and the newer and better PDO_*. Do not use MYSQL_* anymore since this api has been deprecated for long and has been removed since PHP 7. Also do not mix different API in the same page and learn about prepared statements – Lelio Faieta May 04 '18 at 09:57
  • same as it does in any other environment. Install all the components, point your PHP script at the correct location of the database, run the code (via the webserver). When you had the scripts on your paid host, you'd have had to write the location of the database into your PHP - either hostname or IP address. You have to do the same for this. If they're on the same machine, "localhost" is likely to be sufficient, assuming you set up your SQL instance and users correctly. Setting up and installing a LAMP stack is a bit beyond the scope of a single SO question. Easy to use packages exist, though – ADyson May 04 '18 at 10:00
  • Possible duplicate of [PDO and MariaDB](https://stackoverflow.com/questions/16195013/pdo-and-mariadb) – William Perron May 04 '18 at 12:03

0 Answers0