Grodo Posted May 13, 2008 Share Posted May 13, 2008 How can I run a check on $admin to see if the connection to the db was successful? $admin echos out Resource id #1 when the connection is successful or displays the error if it isnt. However I can not check if $admin=='Resource id #1' for some reason. It just tends to ignore that the check is even there. if(isset($_POST["submit"])) { $admin=openDB($_SERVER['SERVER_ADDR'],msql_database,$_POST['username'],$_POST['password']); } else { show_admin(); } and this is the openDB function function openDB($server,$db,$user,$password) { $MYSQL_Server = $server; $MYSQL_DB = $db; $MYSQL_User = $user; $MYSQL_Password = $password; // Connect to database $dbID = mysql_connect($MYSQL_Server, $MYSQL_User, $MYSQL_Password) or die("<p>Unable to connect to the ' . 'database server at this time.</p>"); mysql_select_db( $MYSQL_DB ) or die("'<p>Unable to locate Catalog Request ' . 'database at this time.</p>'"); return( $dbID ); } and this is the showAdmin function function show_Admin() { global $HTTP_POST_VARS; ?> <form method="post" action=""> <table bord"0" width="100%" cellpadding="5" cellspacing="0"> <tr> <td><b>Username</b></td> <td><input type="text" name="username" size="25"></td> </tr> <tr> <td><b>Password</b></td> <td><input type="text" name="password" size="25"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </table> <?php } Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 13, 2008 Share Posted May 13, 2008 if the connection isn't successful, you'll see the die() errors in the function. Quote Link to comment Share on other sites More sharing options...
Grodo Posted May 13, 2008 Author Share Posted May 13, 2008 Ok I figured it to check against resources you have to use the is_resource function in php http://us2.php.net/manual/en/function.is-resource.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.