Anyone who knows this error ?

Fatal error: Uncaught Error: Cannot use object of type mysqli_result as array in C:\xampp\htdocs\Racks Web\ForgotPassword.php:21 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Racks Web\ForgotPassword.php on line 21

here's my code :

<?php

function itexmo($number,$message,$apicode){
$ch = curl_init();
$itexmo = array('1' => $number, '2' => $message, '3' => $apicode);
curl_setopt($ch, CURLOPT_URL,"https://www.itexmo.com/php_api/api.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query($itexmo));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return curl_exec ($ch);
curl_close ($ch);
}
//##########################################################################

    if (isset($_POST['approve']))
    {
        $connect = mysqli_connect("localhost", "root", "", "racks"); 
        $query = "SELECT password FROM admin Where phonenumber = '********'"; 
        $result = mysqli_query($connect, $query);
        $number = "*******";
        $message = "Hi this is a test".$result['password'];
        $apicode = "TR-********";
        $result = itexmo($number,$message,$apicode);
        if ($result == "")
        {
                        echo "iTexMo: No response from server!!!
                        Please check the METHOD used (CURL or CURL-LESS). If you are using CURL then try CURL-LESS and vice versa. 
                        Please CONTACT US for help. ";
        }
                else if ($result == 0)
                {
                }
                else
                { 
                echo "Error Num ". $result . " was encountered!";
                 }
    }              

?>

    $result is either false or a mysqli_result. So, you need to check that it is not false, and if so, you need to call mysqli_fetch_assoc with it to get the array you want. You cannot directly write $result['password'].

      Write a Reply...