PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, May 17, 2022

[FIXED] How to convert mysql_result to mysqli result in this example?

 May 17, 2022     mysqli, php     No comments   

Issue

I understand how to fetch a result in mysqli, but how would this example be coded for mysqli?

$t=mysql_query($query);
return (mysql_result($t, 0) === '1') ? true : false; 

The first line is easy, but how do you do the second line?

$t=mysqli_query($mysqli, $query);
return (mysql_result($t, 0) === '1') ? true : false; 

I replaced mysql_result with mysqli_result, and it seemed to work, but my editor doesn't recognise mysqli_result as a part of php.

Just want to check that this is the correct way.


Solution

Try

$t=mysqli_query($mysqli, $query);
return (mysqli_result($t, 0) === '1') ? true : false; 


function mysqli_result($res, $row, $field=0) { 
    $res->data_seek($row); 
    $datarow = $res->fetch_array(); 
    return $datarow[$field]; 
} 


Answered By - vijaykumar
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing