How to use PHP & MySQL Connect to Database Learn PHP how to using PHP connect to MySQL Database.
ShotDev Focus:
- Test a connect to MySQL Database
Example
php_mysql.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $objConnect = mysql_connect("localhost","root","root"); if($objConnect) { echo "Database Connected."; } else { echo "Cannot Connect to MySQL = ".mysql_error(); } mysql_close($objConnect); ?> </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_mysql.php
Screenshot