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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.