Jump to content

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given i


Recommended Posts

Please can someone help me out... when i run my program i have this error message;

 

"Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\collegepro1.3\parent_report_sheet.php on line 240"

 

Please find below the codes:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>:: WELCOME TO THE SCHOOL MANAGEMENT SYSTEM ::</title>

<style type="text/css">

<!--

#Layer1 {

position:absolute;

width:215px;

height:139px;

z-index:1;

left: 453px;

top: 287px;

background-color: #CC9900;

}

#Layer2 {

position:absolute;

width:217px;

height:32px;

z-index:2;

left: 451px;

top: 251px;

background-color: #333399;

}

#Layer3 {

position:absolute;

width:619px;

height:154px;

z-index:3;

left: 254px;

top: 26px;

}

#Layer4 {

position:absolute;

width:724px;

height:649px;

z-index:1;

background-color: #CCCCCC;

left: 202px;

top: 1px;

}

#Layer5 {

position:absolute;

width:721px;

height:22px;

z-index:1;

top: 98px;

left: 2px;

background-color: #99CC99;

}

#Layer6 {

position:absolute;

width:721px;

height:31px;

z-index:2;

top: 136px;

left: 8px;

background-color: #336699;

}

#Layer7 {

position:absolute;

width:158px;

height:504px;

z-index:3;

left: 8px;

top: 173px;

background-color: #006633;

}

#Layer8 {

position:absolute;

width:517px;

height:115px;

z-index:4;

left: 170px;

top: 20px;

}

-->

</style>

</head>

<link href="Level3_1.css" rel="stylesheet" type="text/css" />

<body>

 

<?php

session_start();

 

if (session_id() !=($_SESSION["Sess_ses"]) || ($_SESSION["w_use_typ"]) != 'C'){

 

header("Location: default_to_entergrade.php");

 

}

 

//*

// contacts_menu.php

// Contacts Section

// Main Menu

//*

 

//Check if contact is logged in

session_start();

if(!session_is_registered('UserId') || $_SESSION['UserType'] != "C")

  {

    header ("Location: index.php?action=notauth");

exit;

}

?>

 

<?php

function Set_criteria($all){

 

$result = "";

$id = $all["student"];

$term = $all["term"]; 

$session =  $all["session"];

 

if($id=="" || $term == "" || $session == ""){

 

$result = "error";

 

}

 

if($id != "" && $term != "" && $session != ""){

$_SESSION['nam_id'] = $id;

$_SESSION['term'] = $term;

$_SESSION['sess'] = $session;

 

$mycon = mysqli_connect("localhost","wfuser","wfpass","palasis");

$get_sql = "

Select

concat(studentbio.studentbio_lname,studentbio.studentbio_fname,studentbio.studentbio_mi) as Name

    from studentbio Where studentbio_internalid = '".$id."'";

 

$get_res = mysqli_query($mycon, $get_sql) or die(mysqli_error($mycon));

 

if(mysqli_num_rows($get_res) <= 0){

$result = "empty";

 

}

 

 

if(mysqli_num_rows($get_res) >= 1){

$result = $get_res;

 

}

 

 

}

 

 

mysqli_close($mycon);

 

 

return $result;

}

//end of function set-criteria

 

$tname = $_SESSION["w_userna"];

$parid = $_SESSION["w_relid"];

 

$mycon = mysqli_connect("localhost","wfuser","wfpass","palasis");

 

$display_welcome_name = "     <b><font size=\+2 color=\"#FFFFFF\">Welcome   $tname</font></b>";

$display_date = "<font color=\"#FFFFFF\"><b>".date("l F  jS\,  Y.")."</b></font>";

 

$display_block = "

<form  method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\" enctype=\"multipart/form-data\">

<table  align=\"justify\">

<tr>

<td>   

 

<select name=\"student\">

<option value=\"\">-Select Ward's Name-</option>";

 

//$get_sql = "Select ward_name, ward_id from ward_parent where ward_contact_id = ".$t_id."";

$get_sql = "select studentbio_internalid, studentbio_id, concat(studentbio_lname, studentbio_fname) as ward_name from studentbio where studentbio_primarycontact = '".$parid."' order by studentbio_fname";

$get_res = mysqli_query($mycon, $get_sql) or die(mysqli_error($mycon));

 

while ($get_array = mysqli_fetch_array($get_res)){

$w_nam = $get_array['ward_name'];

$w_id = $get_array['studentbio_internalid'];

$display_block .="<option value=\"".$w_id."\">".

$w_nam."</option>";

}

$display_block .= "</select>

 

<select name=\"term\">

 

<option value=\"\">-Select Term-</option>";

 

$get_sql = "Select grade_terms_desc from grade_terms order by grade_terms_desc asc";

$get_res = mysqli_query($mycon, $get_sql) or die(mysqli_error($mycon));

 

while ($get_array = mysqli_fetch_array($get_res)){

$cat = $get_array['grade_terms_desc'];

$display_block .="<option value=\"".$cat."\">".

$cat."</option>";

}

$display_block .= "</select>

 

<select name=\"session\">

<option value=\"\">-Select Session-</option>";

 

$get_sql = "Select school_years_desc from school_years order by school_years_id desc";

$get_res = mysqli_query($mycon, $get_sql) or die(mysqli_error($mycon));

 

while ($get_array = mysqli_fetch_array($get_res)){

$cat = $get_array['school_years_desc'];

$display_block .="<option value=\"".$cat."\">".

$cat."</option>";

}

$display_block .= "</select>

 

 

<input type=\"submit\" value=\"Generate\" />

</td>

</tr>

</table>

</form>";

 

if($_POST){

 

$all_post = $_POST;

$get_list = Set_criteria($all_post);

 

}

 

if($get_list == 'error'){

 

$display_list = "<font Color=\"#990000\">    Please ensure selection is made from ALL the drop-downs</font>";

 

}

 

if($get_list == 'empty'){

 

$display_list = "<font Color=\"#990000\">    No reports available yet.</font>";

 

}

 

 

if(mysqli_num_rows($get_list) >= 1){

$get = mysqli_query($mycon,"Select * from result_handler Where student_internalid = '".$_SESSION['nam_id']."' AND term = '".$_SESSION['term']."' AND school_year = '".$_SESSION['sess']."'");

$class = mysqli_fetch_array($get);

$grad = $class['grades_desc'];

$arm = $class['grades_arm'];

$name = $class['student_name'];

 

if(($grad == 'S.S. 1 ' )|| ($grad == 'S.S. 2 ') || ($grad == 'S.S. 3 ')){

$getpage = 'Performance_report_senior.php';

}else{

$getpage = 'Performance_report_junior.php';

}

 

while ($get_array = mysqli_fetch_array($get_list)){

$num = $num + 1;

$name =  $get_array['Name'];

 

$display_list .= "

<br/><br/>

<form target=\"_blank\" method=\"GET\" action=\"".$getpage."\">

<table border=\"0\" bgcolor=\"#66CC66\" width=\"800\">

<tr>

<td bgcolor=\"#FFFFFF\" align=\"left\" ><font size=\"-1\">  ".$name."</font></td>

<td bgcolor=\"#FFFFFF\" align=\"left\" ><font size=\"-1\">  ".$grad." ".$arm."</font></td>

<td bgcolor=\"#FFFFFF\" align=\"left\" ><font size=\"-1\">  ".$_SESSION["sess"]."</font></td>

<td bgcolor=\"#FFFFFF\" align=\"left\" ><font size=\"-1\">  ".$_SESSION["term"]."</font></td>

<td><input type=\"hidden\" name=\"numero\"  value=\"".$_SESSION["nam_id"]."\" ></td>

<td><input type=\"hidden\" name=\"term\"  value=\"".$_SESSION["term"]."\" ></td>

<td><input type=\"hidden\" name=\"session\"  value=\"".$_SESSION["sess"]."\" ></td>

<td><input type=\"submit\" value=\"Print Report\"/></td>

</tr>";

 

 

}

"</table>

 

</form>";

mysqli_close($mycon);

 

}

 

 

 

 

?>

 

 

<!--<div id="Layer5"><?php //echo "$display_welcome_name"; ?></div> -->

<br /><br /><br /><br />

<table width="100%"  height="22px"  bgcolor="#006633">

<tr><td width="40%">  <?php echo "$display_date"; ?></td><td width="30%"><font color="#FFFFFF" size="+1"><b>VIEW REPORT SHEET</b></font></td><td width="30%"><?php echo "$display_welcome_name"; ?></td></tr></table>

<table width="100%"  height="37px"  bgcolor="#006633"  frame="above" >

<tr><td width="35%">                                               <font color="#FFFFFF">[select Name, Term, Session and click Generate]</font></td>

<td width="65%"><?php echo "$display_block"; ?></td>

</tr></table>

 

 

<!--<div id="Layer6"></div> -->

 

<div id="Layer7">

<table width="100%"  cellpadding=1 cellspacing=0 >

        <tbody >

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="Welcome_parent.php"><font color="#FFFFFF"><b>Main Menu</b></font></a></td>

        </tr>

<tr>

<td><hr/></td>

</tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Attendance Notes</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Discipline Notes</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="parent_vw_sheet.php"><font color="#FFFFFF"><b>Performance Report</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="parent_report_sheet.php"><font color="#FFFFFF"><b>Report Sheet</b></font></a></td>

        </tr>

 

<tr>

    <td><hr/></td>

</tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Homework</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Forum</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>News</b></font></a></td>

        </tr>

<tr>

<td><hr/></td>

</tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Timetable</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Health</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Exams and Tests</b></font></a></td>

        </tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="#"><font color="#FFFFFF"><b>Change Password</b></font></a></td>

        </tr>

<tr>

<td><hr/></td>

</tr>

<tr onmouseover="bgColor='#669966'"  onmouseout="bgColor='#006633'">

        <td  valign=center  align=center><a href="logout.php"><font color="#FFFFFF"><b>Logout</b></font></a></td>

        </tr>

 

    </tbody>

  </table>

<!--   <table  bordercolorlight="#FFFF66" -->

    <div id="Layer8"><?php echo "$display_list"; ?></div>

</div>

</body>

</html>

 

The error message is pretty clear in its meaning.  In order to use mysqli_num_rows(), the first argument passed into it must be a mysqli_result.  What is that?  The result of a database query.

 

What does your Set_criteria() function do?  I'm willing to bet it doesn't return a mysqli_result.

wht then do u advice? i need practical steps.

Thanks alot

 

 

Well, the 'simplest' thing to do would be to ensure that your Set_criteria() function returns a mysqli_result that mysqli_num_rows() can read.

 

What does Set_criteria() do?

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.