[英]$rows doesnt work anymore
I tried to upgrade my working mysql script to mysqli but I'm having some problems with my $rows variable.. $rows doesn't return anything anymore.. echo $rows; 我试图将可用的mysql脚本升级到mysqli,但是$ rows变量遇到了一些问题。$ rows不再返回任何内容。 returns blanc.
返回blanc。
here's my code:\\ 这是我的代码:\\
<?php
$host = "***";
$user = "***";
$pwd = "***";
$db_name = "name";
$link = mysqli_connect($host, $user, $pwd, $db_name)or die("cannot connect");
$sql = mysqli_query($link, "SELECT * FROM foto ORDER BY id DESC LIMIT 25") or die(mysqli_error($link));
//var_dump($sql);
while ($rows = mysqli_fetch_assoc($sql))
{
echo "<img class='littleshow'"."id='foto".$rows[$id]."'src='".$rows[$foto]."' onclick='Bigscreen(this)'></img>";
}
?>
thanks for helping :) 感谢您的帮助:)
Variables $id and $foto are not defined anywhere, change it to this and you will see there is output echoed, assuming there are rows returned by the query. 变量$ id和$ foto没有在任何地方定义,将其更改为该变量,您将看到回显输出,并假设查询返回了行。 ($rows[$id] = $rows['id'])
($ rows [$ id] = $ rows ['id'])
while ($rows = mysqli_fetch_assoc($sql))
{
echo "<img class='littleshow'"."id='foto".$rows['id']."'src='".$rows['foto']."' onclick='Bigscreen(this)'></img>";
}
echo $rows;
returns blank means there was no rows returned by the query. 返回空白意味着查询没有返回任何行。
it's also worth to set full error reporting in PHP to see possible mistakes: 还有必要在PHP中设置完整的错误报告以查看可能的错误:
error_reporting(E_ALL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.