Jump to content

[SOLVED] How to form a check against Resource Id #1


Grodo

Recommended Posts

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
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.