In this example, we will try to connect localhost server by
using php codes. So, I hope you've already installed apache and mysql
services in your computer and created a dabase. If you have not
installed, please go to Using MySQL Service in Windows.
Write the following codes and save it as connect.php under C > xampp > htdocs.
<?php
$server = 'localhost';
$username = 'root';
$password = '';
$database = 'tnw';
$error = 'Error! Could not connect to database';
if(mysql_connect($server, $username, $password) || mysql_select_db($database)) {
echo 'Successfully connected to server';
}else{
echo $error;
}
?>
And then, open your web browser and type localhost/connect.php in it . You will see 'Successfull connected to server' .
**Thank You**
My Invitation
Download Android Application
No comments:
Post a Comment