Fatal error: Uncaught Error: Call to undefined function mysqli_result()


i need to get a one value from a  table  and store it in a variable using this code  
$OwnerName= mysqli_result(mysqli_query($con,"SELECT Name FROM buyer WHERE usersId='$client_id'"),0);
but it con't work.

Please I need your helps!
NIYONSE SchaddyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Provide more context.

Likely you're calling mysqli_connect() from PHP.

So, first dump your phpinfo() output + ensure your hosting environment has install the PHP mysql extension.

Probably this extension is missing + will have to be installed, to clear your error.
Julian HansenCommented:
Rule #1 in programming - there are no shortcuts.
Don't do this
$OwnerName= mysqli_result(mysqli_query($con,"SELECT Name FROM buyer WHERE usersId='$client_id'"),0);

Open in new window

1. It is a nightmare to read
2. You have no control over the process if things go wrong

Personally I prefer the OOP version of the library - it is far more intuitive but we will work with the procedural version. Here is how I would do this

$query = "SELECT Name FROM buyer WHERE usersId='{$client_id}'"
$result = mysqli_query($con,$query)
if ($result) {
    $row = mysqli_fetch_object($result);
    echo "Name is {$row->Name}";
else {
   echo "Error: " . mysqli_error($con);

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
I agree with Julian, I never combine functions like that.  Make them separate statements as he shows above.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Poster has stopped posting, so appears Julian's answer is likely best.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.