I want to retrieve records in my database in order to manage details. The below error message displayed when i trying to do that. Can anyone help me out?

( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Student registration\manage student details\manageStudentDetailsForm.php on line 250

<?php

$class_id='0';
$amount_id='0';

$query="SELECT * FROM student_info where student_info.admission_no='$admission_no'";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$s_id=$row['st_id'];
$first=$row['admission_no'];
$sec=$row['admission_date'];
$third=$row['full_name'];
$forth=$row['name_with_initial'];
$fifth=$row['date_of_birth'];
$sixth=$row['religion'];
//$seven=$row['gender'];
$eight=$row['address'];
$nine=$row['telephone_no'];
$ten=$row['grade_on_admission'];
$leven=$row['password'];
$twoel=$row['st_house'];
$description_about_st=$row['description_about_st'];
}

$query2="SELECT class_id FROM student_class where admission_no='$admission_no'
         AND year='$year'";

$result2=mysql_query($query2);
         while($row2=mysql_fetch_array($result2)){
         $class_id=$row2['class_id'];
}

$query3="SELECT class_name,grade_id,stream FROM class where class_id='$class_id'";
$result3=mysql_query($query3);
         while($row3=mysql_fetch_array($result3)){
         $class_name=$row3['class_name'];
         $grade_id=$row3['grade_id'];
         $stream=$row3['stream'];
}

$query="select amount_id from payment where admission_no='$admission_no'";
$result=mysql_query($query);while($row = mysql_fetch_array($result)){ **            **// line 250
        $amount_id=$row['amount_id'];
}

$query="select payment_value from payment_amount  where amount_id='$amount_id' and date like '$year-%'";
$result=mysql_query($query);
        while($row = mysql_fetch_array($result)){
        $payment_value=$row['payment_value'];
}

?>

Hey,

This might be wrong, I haven't ran it.. But, if this is all in the same .php file, then surely you've already defined $result above? So when you do this:

$query="select amount_id from payment where admission_no='$admission_no'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ ** **// line 250
$amount_id=$row['amount_id'];
}

Maybe that is what is triggering it.

This is telling you that the variable in your query is empty. Try echoing out the query to make sure it is as expected and then run what is echo'd out directly in phpMyAdmin to see if you get any errors there as well.

$query="select amount_id from payment where admission_no='$admission_no'";
echo $query;

I tried echoing and it generates result. The query was not empty. It says,

" select amount_id from payment where admission_no='2012/2' ".

And have you run this in phpmyadmin to see what result or error you get directly from the query in the database?

I would double check that $admission_no has a value assigned to it. The rest of the query seems to be fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.