Here is php script to test database Connection, it will need little edition as per your database name and password
Here you go
Just copy and paste below code :-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
< ?php ###################################### C O P Y R I G H T S ############################################ # THIS SIMPLE SCRIPT IS DISTRIBUTED BY WWW.MYLITERATURETECHLIFE.COM UNDER LICENSE UNDER THE GPL RULES # # PLEASE DO NOT REMOVE THIS MESSAGE IN SUPPORT OF OUR HARD WORK TO CONTINUE TO PROVIDE FREE SUPPORT # ####################################################################################################### ############ Define hostname ############# ## Replace "localhost" with your mysql host name or Ip address ## define ("HOSTNAME","localhost"); ############ Define username ################### ## Replace "db_usname" with your Database Username ## define ("USERNAME","db_usname"); ############ Define password ################### ## Replace "db_passwd" with your Database password ## define ("PWD","db_passwd"); ############ Define database ################### ##Replace "db_name" with your Database name ## define ("DBNAME","db_name"); ####link to mysql server#### if($link = mysql_connect (HOSTNAME,USERNAME,PWD)) { print "<h1>Connection to MySQL server Successful<br />\n"; } else { die ("<h1>Cannot connect to MySQL server.</h1><br />\n" . mysql_error()); } ####selecting a database#### if (mysql_select_db (DBNAME , $link)) { print "<h2>Connection to Database Successful</h2><br />\n"; } else { die ("<h2>Cannot select database.</h2><br />\n" . mysql_error()); } print "<br /> <div align='center'> <img src='http://www.techat.net/logo.gif'/> </div> <div align='center'> <a href='http://www.techat.net.com'>Technical Literature</a></div>"; ?> |
Comment Policy:
Your words are your own, so be nice and helpful if you can. Please, only use your real name, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.