MySQL Database Connection using php
php uses mysql_connect function to open the database this function will return true or false Syntax —— mysql_connect(server,user,passwd); Server–its actualy hostname running database server this value as localhost or localhost:3306 user-username for accessing the dtabase passwd-password of the database Examples
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $databasehost = 'localhost'; $databasebuser = 'root'; $databasebpass = ''; $connection = mysql_connect($databasebhost, $databasebuser, $databasebpass); if(! $connection ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($connection); ?> |