今天升级了php版本,顺便想把php代码中的mysql连接方式改成mysqli,因为官方自php5.3开始一直推荐mysqli 和 pdo 。不多说了,贴代码
<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官方网址:http://php.net/manual/zh/function.mysql-result.php
以上就介绍了php中mysqli替换mysql_result的官方方法,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。