Home > Article > Backend Development > The official method to replace mysql_result with mysqli in php
I upgraded the php version today, and by the way, I want to change the mysql connection method in the php code to mysqli, because the official has been recommending mysqli and pdo since php5.3. Not much to say, just post the code
<code><span>// here's a rough replacement using mysqli:</span><span>// 错略的使用mysqli替换</span><span>if</span> (!function_exists(<span>'mysql_result'</span>)) { <span><span>function</span><span>mysql_result</span><span>(<span>$result</span>, <span>$number</span>, <span>$field</span>=<span>0</span>)</span> {</span> mysqli_data_seek(<span>$result</span>, <span>$number</span>); <span>$row</span> = mysqli_fetch_array(<span>$result</span>); <span>return</span><span>$row</span>[<span>$field</span>]; } }</code>
php official website: http://php.net/manual/zh/function.mysql-result.php
The above introduces the official method of replacing mysql_result with mysqli in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.