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 } Link to comment https://forums.phpfreaks.com/topic/105485-solved-how-to-form-a-check-against-resource-id-1/ 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. Link to comment https://forums.phpfreaks.com/topic/105485-solved-how-to-form-a-check-against-resource-id-1/#findComment-540295 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 Link to comment https://forums.phpfreaks.com/topic/105485-solved-how-to-form-a-check-against-resource-id-1/#findComment-540301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.