我的 php 代码有点问题..
$stmt = $db->prepare("SELECT * FROM mytable WHERE TheGroup = :SearchName ORDER BY TheTime DESC");
$stmt->bindParam(':SearchName', $request, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = count($result);
for ($i = 0; $i < $count; $i++) {
$mTheAvatar = $result[$i]->TheAvatar;
$mTheDirection= $result[$i]->TheDirection;
$mTheGroup = $result[$i]->TheGroup;
$mTheMedia = $result[$i]->TheMedia;
$mTheMessage = $result[$i]->TheMessage;
$mTheSenderName= $result[$i]->TheSenderName;
$mTheThumbImage = $result[$i]->TheThumbImage;
$mTheTime = $result[$i]->TheTime;
$mTheMediaExtension = $result[$i]->TheMediaExtension;
echo "hello";
echo $mTheAvatar;
echo " <- this is avatar";
}
如果我执行 Var_dump(),我会看到所请求的数据没有问题。 如果我回显变量,它们是空白的.. 我已经三次检查表列名称是否正确..
$mTheAvater 是表格中的图片,如果它提供了可能的线索,但其余部分也是空白的,所以不确定发生了什么?!?
最佳答案
你可以测试:
$mTheAvatar = $result[$i]['TheAvatar'];
正如我在 FETCH_ASSOC
中所知,它返回上述结构中的数据。
关于PHP Mysql 取数据空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37274901/