HostingInsider
04-04-2005, 10:22 PM
I am working on a PHP/MySQL program and have a question.
It includes a browser-based installation wizard, and on the page after the user inputs their MySQL connection information, I am having it do a check to ensure that the information they inputted was correct. Here is the code I have:
<?php
// This parts define the MySQL database access info to be used in the databse connection test
define ('DBHOST', $_POST[databasehost]);
define ('DBUSER', $_POST[databaseuser]);
define ('DBPASSWORD', $_POST[databasepassword]);
define ('DBNAME', $_POST[databasename]);
// This part attempts to make the connection and displays any error messages
$dbc = @mysql_connect (DBHOST, DBUSER, DBPASSWORD) OR die ('Could not connect to MySQL, please check login details, error message: ' . mysql_error());
@mysql_select_db (DBNAME) OR die ('Could not select the database, error message: ' . mysql_error());
?>
Here's my question: How would I have it display a message if everything checks out fine. I know it would probably be an if statement, but what would I put in the statement? For example, I want it to say:
The test connection to your MySQL database was made successfully!
Could someone please help me out here? Thanks for your input.
It includes a browser-based installation wizard, and on the page after the user inputs their MySQL connection information, I am having it do a check to ensure that the information they inputted was correct. Here is the code I have:
<?php
// This parts define the MySQL database access info to be used in the databse connection test
define ('DBHOST', $_POST[databasehost]);
define ('DBUSER', $_POST[databaseuser]);
define ('DBPASSWORD', $_POST[databasepassword]);
define ('DBNAME', $_POST[databasename]);
// This part attempts to make the connection and displays any error messages
$dbc = @mysql_connect (DBHOST, DBUSER, DBPASSWORD) OR die ('Could not connect to MySQL, please check login details, error message: ' . mysql_error());
@mysql_select_db (DBNAME) OR die ('Could not select the database, error message: ' . mysql_error());
?>
Here's my question: How would I have it display a message if everything checks out fine. I know it would probably be an if statement, but what would I put in the statement? For example, I want it to say:
The test connection to your MySQL database was made successfully!
Could someone please help me out here? Thanks for your input.
