MySQL Forums
Forum List  »  PHP

Using mysqli_connect()
Posted by: sorcerer stone
Date: April 27, 2020 09:08AM

My OS is Win10 (with latest update).
I installed manually Apache, MySQL, PHP (with default settings for each packages).
I have imported a database using MySQL command line. The database is located in the default directory: "C:\ProgramData\MySQL\MySQL Server 8.0\Data".
MySQL placed this database and all its tables inside a folder that bears the name of the database eg. MyTestDB.

I am learning how to query database in a php file. However, most of the examples I see in YouTube used the WAMP or XAMP setups where all individual modules are connected during install. So, in these setups, one can query MySQL database using the followings:

$servername = "localhost";
$database = "database";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);

In my case, where I manually installed these component, how do I tell in my php script

1/ where MySQL is located on my laptop
2/ which directory the database is located? is it something like $database = "C:\ProgramData\MySQL\MySQL Server 8.0\Data\MyTestDB"
3/ How to modify the above mysqli_connect() statement in order to fit my setup for connecting to my database (MyTestDB)?
4/ Do I need additional statement(s) to connect to the MySQL engine on my laptop?

Thanks in advance.

Options: ReplyQuote

Written By
Using mysqli_connect()
April 27, 2020 09:08AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.