0

I have two pages . In the first page if user will click on button then he will get relavant data with id column

<form action='edit.php?id=$id' method='post' name='edit_btn'> 
<button type='submit' class='w3-btn w3-red w3-round-xlarge'>Proceed </button> 
</form>   

        $con=mysqli_connect("localhost","root","","student_result_info_db");if (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }else{ 
          if(isset($_GET['edit_btn'])){
              echo "<div class='w3-container w3-red'> <h1>>Error Found!</h1> <h4>OK You Did Hit The EDIT Button</h4> </div> <br/>";
          }else{  
             $get_selected_id = $_GET['id'];
             echo $get_selected_id;

             $res = "SELECT * FROM school_result";


                 while ($row = mysql_fetch_array($res)){
                     echo "$row[id]. $row[first_name] <br/>";
                     echo "$row[id]. $row[last_name] <br/>";
                 } 
          }
    }

It'showing following error

Fatal error: Call to undefined function mysql_fetch_array() in

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

2 Answers2

0

Use mysqli_fetch_array instead, along with mysqli_query to get a mysqli_result object:

$qresult = mysqli_query($con, $res);
while ($row = mysqli_fetch_array($qresult)){

You need to use this for 2 reasons:

  1. You opened your database using mysqli_connect, so you need to use the mysqli functions.

  2. mysql functions were removed in PHP 7.

Aaron Christiansen
  • 11,584
  • 5
  • 52
  • 78
0

Use mysqli function instead of mysql like

mysqli_query($con, $res);
Jatin Raikwar
  • 406
  • 5
  • 17
  • it's show error **Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in** – Gourab Mazumder Mar 17 '16 at 12:53
  • have you used mysqli_query function – Jatin Raikwar Mar 17 '16 at 12:56
  • It's fetching but here is a problem . In the db many rows of data was inserted and now **I need fetch only which row that column `ïd` is matching** and it also showing a error **Fatal error: Maximum execution time of 30 seconds exceeded in** – Gourab Mazumder Mar 17 '16 at 13:28