今天升級了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教學有興趣的朋友有幫助。