dsaj20411 2014-02-20 13:23
浏览 49
已采纳

将MySQL输出写入变量时的“数组到字符串转换”

I'm trying to write the output of a MySQL select into a variable. The problem is that i get the error "Array to String conversion".

    $user = mysql_query("select username from user");
echo "<table border='1'>";
if (isset($_POST['winneron'])) {
    echo "<tr>";
    while ($printuser = mysql_fetch_array($user)) {
        echo "<th align='center'>". $printuser['username'] . "</th>";
    }
    echo "</tr>";
    $user = mysql_query("select username from user");
    while ($printuser = mysql_fetch_array($user)) {
        $games = mysql_query("SELECT s.spielid, date, team1, team2, sieger, wettid, u.userid, w.spielid, team 
                              FROM user u, spiele s, wette w 
                              WHERE u.userid = w.userid 
                              AND u.username = '$printuser' 
                              AND w.spielid = s.spielid"); <-- Error line
        while ($printgames = mysql_fetch_array($games)) {
            if ( $printgames['sieger'] == $printgames['team1'] ) {
                echo "<tr><td align='center'><b>". strtoupper($printgames['sieger']) . "</b></td></tr>";    
            }
            else { 
                echo "<tr><td align='center'>". strtoupper($printgames['sieger']) . "</td></tr>"; 
            }
        }
    }
}
  • 写回答

2条回答 默认 最新

  • doujingxi3356 2014-02-20 13:28
    关注

    AND u.username = '$printuser' replace it with AND u.username = '".$printuser['username']."'

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器