0

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.

Edited by hanspeare: add codes

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by hanspeare
1

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.