gpt4 book ai didi

php - 警告 : Illegal string offset - PHP mySQL

转载 作者:行者123 更新时间:2023-11-29 07:54:37 25 4
gpt4 key购买 nike

警告:第 82 行/opt/lampp/htdocs/linom/index.php 中存在非法字符串偏移“slimg”

<?php
$slider = "SELECT * FROM post ORDER BY id ASC LIMIT 4";
$slider1 = mysqli_query($connect,$slider);
$sliderV = mysqli_fetch_array($slider1);

do {
printf ("<div class='slider'>
<a href='view.php?id=%s'>
<figure>
<img class='slideimg' src=%s>
<figcaption>
%s
</figcaption>
</figure>
</a>
</div>",$sliderV['id'],$slider['slimg'],$sliderV['title']); //here is error
}
while ($sliderV = mysqli_fetch_array($slider1));
?>

最佳答案

你的变量名不是很清楚。您不小心引用了查询字符串而不是数组:

$sliderV['slimg']

我建议使用更好的变量名称,例如 $slider_sql$slider_query$slider

关于php - 警告 : Illegal string offset - PHP mySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25488247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com