Hello PHP fanatics,

The browser shows

Warning: mysql_numrows() expects parameter 1 to be resource, array given in C:\xampp\htdocs\a\Student_Home.php on line 13

here is the line 13...

the LINE 5 is the LINE 13.

include 'Connect.php';
    $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES);
    $result = mysql_query("SELECT * FROM student_information where student_id='$_GET[id]'");
    $data = mysql_fetch_array($result);
    $numRows = mysql_numrows($data);
    $i = 0;

Please advise what is wrong.
Kindly edit my codes.

It should be $result, not $data, the correct one is $numRows = mysql_numrows($result)

Also, you've already assigned student's ID to $student_id variable, why $_GET['id'] in your sql and it was not filter properly. And mysql is deprecated and there is new mysqli and PDO for more secure database communication.

hello coco,

i followed your advise in the variable $numRows and this is now my code.

<?php
    session_start();
    $session_id = $_SESSION['admin_id'];
    if($session_id == null){
       header("location:Admin_Home.php");
       die();
    }

    include 'Connect.php';
    $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES);
    $result = mysql_query("SELECT * FROM student_information where student_id='$_GET[id]'");
    $data = mysql_fetch_array($result);
    $numRows = mysql_numrows($result);
    $i = 0; 
    while($i < $numRows)  
    ?>
    <img src="display_image.php?id= <?php echo mysql_result($data,$i,"id")?>;" width="175" height="200" /> 

    <?php

    $i++;

    ?>  

This is now the notifications ive got

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\a\Student_Home.php on line 16.

I am using the $_GET['id'] instead of student_id to call the unique id per student.

Sorry for being deprecated but i dont know how to change my current version to my_sqli. But maybe let just take this one by one and focus first on the fatal error notification. Please help.

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.