这是脚本:
<?php
session_start();
$walldir = mysqli_query($connect, "SELECT `launcherwallpaper` from user where `username` = '$id'");
$wallpaper = '../../user/'.$_SESSION['username'].'/'.$walldir;
echo "<style>head {
background: url('".$wallpaper."') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}</style>";
?>
和数据库数据:
launcherwallpaper
Image/default.jpg
谁能帮助我,谢谢!
最佳答案
这就是你要做的
$walldir = mysqli_query($connect, "SELECT `launcherwallpaper` from user where `username` = '$id'");
$result_set = mysqli_fetch_assoc($walldir);
$wallpaper = '../../user/'.$_SESSION['username'].'/'.$result_set['launcherwallpaper'];
始终至少阅读Basics tutorial
关于php - 可捕获的 fatal error :第6行的类mysqli_result的对象无法转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28526363/