Альтернативой является использование PDO ...
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="ureviewdu"; // Database name
$tbl_name="Student"; // Table name
$return='';
if(isset($_POST)){
$continue=true;
if(empty($_POST['reguser']) || strlen($_POST['reguser']) < 3){$continue=false;}
if(empty($_POST['regpass']) || strlen($_POST['regpass']) < 6){$continue=false;}
if(empty($_POST['regfirst']) || strlen($_POST['regfirst']) < 3){$continue=false;}
if(empty($_POST['reglast']) || strlen($_POST['reglast']) < 3){$continue=false;}
if(empty($_POST['regemail']) || filter_var($_POST['regemail'], FILTER_VALIDATE_URL)==false){$continue=false;}
if(empty($_POST['regclassrank']) || is_int($_POST['regclassrank'])==false){$continue=false;}
if($continue===true){
//Attempt to insert
try{
$dbh = new PDO("mysql:host=$host;dbname=$db_name", $username, $password);
/*** set the error reporting attribute ***/
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*** variables ***/
foreach($_POST as $key=>$value){
if(get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
$values[$key]=$value;
}
/*** prepare the SQL statement ***/
$stmt = $dbh->prepare("INSERT INTO $tbl_name (uname, pass, fname, lname, email, currGrade)
VALUES(:uname,:upass,:fname,:lname,:email,:currGrade)");
/*** bind the paramaters ***/
$salt = '~Z`!@#$%I^&*()_-+Q=}]{[\|"><';
$stmt->bindParam(':uname', $values['reguser']);
$stmt->bindParam(':upass', sha1($salt.$values['regpass']));
$stmt->bindParam(':fname', $values['regfirst']);
$stmt->bindParam(':lname', $values['reglast']);
$stmt->bindParam(':email', $values['regemail']);
$stmt->bindParam(':currGrade', (int)$values['regclassrank']);
/*** execute the prepared statement ***/
$stmt->execute();
$return='Thanks for signing up!';
/*** close the database connection ***/
$dbh = null;
}catch(PDOException $e){
$return='Failed:'. $e->getMessage();
}
}else{
$return='All fields are required';
}
}
echo $return.
'<form ...........';
?>