dpzbzp8728 2015-12-28 17:28
浏览 34

PHP中的list()和mysqli_fetch_row()

Is it possible to somehow use list and mysqli_fetch_row together? The code below doesn't work.

$query = "SELECT id, email FROM emails WHERE id='24'";
$result = mysqli_query($link, $query);
list($get_id, $get_email) = mysqli_fetch_row($result);

This code however works, but I want a code that is less lines:

$query = "SELECT id, email FROM emails WHERE id='24'";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_row($result);
$get_id = $row[0];
$get_email = $row[1];
  • 写回答

1条回答 默认 最新

  • dousi2029 2015-12-28 17:50
    关注

    You can use the list() like that.

    So there must be an error in your query or somewhere else in your code, so add this code to be sure if there is an error and if so what it is.

    error_reporting(E_ALL); 
    ini_set('display_errors', 1);
    
    $query = "SELECT id, email FROM emails WHERE id='24'";
    $result = mysqli_query($link, $query);
    
    if ( ! $result ) {
        echo mysqli_error($link);
        exit;
    }
    
    list($get_id, $get_email) = mysqli_fetch_row($result);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度