Jump to content

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean


ipsa24

Recommended Posts

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\student info system\student_registration_handler.php on line 33

No database selected

 

 

 

<?php
include 'Connect.php';
$flag = "success";
function rollbackData(){
mysql_query(" ROLLBACK ");
global $flag;
$flag = "error";
if(mysql_error() != null){
die(mysql_error());
}
}
$student_id = $_POST['st_id'];
$student_pass = $_POST['st_pass'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$gender = $_POST['gender'];
$contact_no = $_POST['contact_no'];
$qualification= $_POST['qualification'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$pin_code = $_POST['pin_code'];
$email1 = $_POST['email1'];
$address = $_POST['address'];
$resumename = "";
$imagename = "";
$dobdate = date("Y-m-d",strtotime($_POST['dob']));
/*
        This block is used to check whether the student_id already exists in database.
*/
$select_query="select student_id from student_information where student_id = '$student_id'";
$result_set = mysql_query($select_query,$link_id);
if($row = mysql_fetch_array($result_set)){
$flag="exists";
header("location:Student_login.php?flag=$flag&student_id=$student_id");
die();
}
else{
/*               This block is used to insert the student record in databaseif the student_id is already not present in the database.
*/
mysql_query("SET AUTOCOMMIT = 0 ");
if(mysql_error() != null){
die(mysql_error());
}
$query = "insert into student_information(student_id,student_password,first_name,last_name,registration_date,gender,date_of_birth,";
$query .="student_status,contact_no,qualification,city,state,country,pin_code,email1,address)";
$query .= "values('$student_id','$student_pass','$first_name','$last_name',now(),'$gender ','$dobdate','Disable','$contact_no',";
$query .="'$qualification','$city','$state','$country','$pin_code','$email1','$address')"; 
$result = mysql_query($query,$link_id);
if(mysql_error() != null){
die(mysql_error());
}
if($result){
if($_FILES['resume']['name'] != ""){
$filename = $_FILES['resume']['name'];
$ext = strrchr($filename,".");
$resumename = $student_id;
$resumename .= "_".$filename;
if($ext ==".txt" || $ext ==".doc" || $ext ==".TXT" ||$ext ==".DOC" || $ext ==".pdf" || $ext ==".PDF"){
$size = $_FILES['resume']['size'];
if($size > 0 && $size < 1000000){
$archive_dir = "resumes";
$userfile_tmp_name =$_FILES['resume']['tmp_name'];
if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$resumename")){
/*
                       if image is successfullyuploaded then resumename is stored in database.
                             */
mysql_query("updatestudent_information set resume='$resumename' wherestudent_id='$student_id'", $link_id);
if(mysql_error() != null){
die(mysql_error());
}
$flag = "success";
}else{
rollbackData();
}
}
else{
rollbackData();
die("You can upload resume of 1 MBsize only. Please, try again.");
}
}
else{
rollbackData();
die("You can upload resume of .txt, .pdf,.doc extensions only. Please, try again.");
}
}
if($_FILES['image']['name'] != ""){
$filename = $_FILES['image']['name'];
$ext = strrchr($filename,".");
$imagename = $student_id;
$imagename .="_". $filename;
if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" ||$ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
$size = $_FILES['image']['size'];
if($size > 0 && $size < 1000000){
$archive_dir = "images";
$userfile_tmp_name =$_FILES['image']['tmp_name'];
if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$imagename")){
/*
                                  if image is successfullyuploaded then imagename is stored in database.
*/
mysql_query("updatestudent_information set image='$imagename' wherestudent_id='$student_id'", $link_id);
$flag = "success";
if(mysql_error()!=null){
die(mysql_error());
}
}
else
{
if(file_exists('resumes/' .$resumename)) {
unlink('resumes/' .$resumename);
}
rollbackData();
}
}
else{
if(file_exists('resumes/' .$resumename)) {
unlink('resumes/' .$resumename);
}
rollbackData();
die("You can upload image of 1 MBsize only. Please, try again.");
}
}
else{
if(file_exists('resumes/' . $resumename)) {
unlink('resumes/' . $resumename);
}
rollbackData();
die("You can upload images of .jpg, .jpeg,.gif extensions only. Please, try again. ");
}
}
}
else{
$flag="error";
}
if($flag == "success"){
mysql_query(" COMMIT ");
$flag="success";
if(mysql_error() != null){
die(mysql_error());
}
/*
                         This block is used to send email to the successfully registered users.*/
/*
                          $to = $email1;$subject = 'Congratulations';$message = 'Congratulations you are registered in our site.\r\n\r\n';
$message .= "Your Login Id : $student_id \r\n Password :$student_pass";
$headers = "From: info@sims.com\r\n";
$headers .= 'X-Mailer: PHP' . phpversion();
mail($to, $subject, $message, $headers);
*/
}
header("location:Student_login.php?flag=$flag");
die();
}
?>

Link to comment
Share on other sites

This is a common error, and it tells you exactly what is wrong. Your passing a boolean to mysql_fetch_array(), it expects a resource.

 

Check your query has actually succeeded before simply using it's result.

 

And please, we have


tags for a reason.

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.