Trending News
Trying to connect to a MySQL DB.?
How would I put a comment in a page that I created (which is designed to connect to a MySQL DB) that would tell me a successful connection was made? Would I use an IF/ELSE statement, WHILE/DO WHILE, etc?
How would I put a comment in a page that implements both HTML and PHP that I created (which is designed to connect to a MySQL DB) that would tell me a successful connection was made? Would I use an IF/ELSE statement, WHILE/DO WHILE, etc?
2 Answers
- splLv 41 decade agoFavorite Answer
Not sure what language you're using... but with PHP I've used:
$link = mysql_connect('DB_name', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
That will tell you if it did not connect. If it did, you could add an else to echo that it did connect.
- jacowayLv 44 years ago
Sounds as besides the indisputable fact that its an recreation and the database on the server end is having issues. you may want to favor to attend a lengthy time period for it to be rebooted or checked into. If its on your computer think ofyou've got deleted MySQL that contained the database. if so you may want to opt to reinstall it