Resource id #2

admin

Administrator
Staff member
Hello everyone,

i wrote a test script to check a MySQL database to see if a particular user id exists by using the following codes.

<?php
###############################################################################
# This script processes the student's application to become a member. It first
# varifys that the userid that the student enter is unique. It also checks for
# the password to be consistent before writing the required information into
# the database for record.
################################################################################

include("lib/MySQL/connection.open.php"); //script for making the connection
include("lib/MySQL/database.variables.php"); //variable names for database

//querying mysql to see if similar user_id is present
$sql_query = "SELECT count(s_user_id) FROM ";
$sql_query .= $student_login_table;
$sql_query .= " WHERE s_user_id='";
$sql_query .= $student_id . "'";

//executing the query
$result = mysql_query($sql_query, $dbLink);

if($result > 0)
{
print("\nSorry, somebody have already chosen that username");
}

//closes the existing connection
mysql_close($dbLink);
?>

much as i try..i keep getting the codes inside the "if-statement" even though i know such a user id does not exist. when i print the result of the query, i get an error telling me "Resource id #2" pls advice thank you!!
 
Back
Top