Good evening. Now I am translating one project from MySQL to MySQLi and this question has arisen. Is there an absolute substitute for the mysql_result() function in PHP ?

 return mysql_result($result, 0); 

What does zero mean is not entirely clear ?!

    1 answer 1

    Depending on how you want to get the result, you can use:

     mysqli_fetch_array() mysqli_fetch_assoc() mysqli_fetch_object() mysqli_fetch_row() 

    I do not know OOP or not you use, but if not OOP, then correct

     $result = $mysqli->query($query) $row = $result->fetch_row(); return $row; 

    If you need to replace say

     mysql_result($result,20); 

    Then you need to move the pointer to a new entry and use the above example for mysqli

     $result = $mysqli->query($query); $result->data_seek(20); $row = $result->fetch_row(); return $row; 
    • Updated the question. It's just that I didn't write the code, I just do refactoring ... - spoilt
    • Updated the answer. 0 this is a record to take. Still slightly corrected, misled with the index. fetch_row already selects the first entry - aldem67
    • Thank you so much, I will try now! - spoilt