首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正在尝试从mysql数据库中检索用户个人资料图片。

问正在尝试从mysql数据库中检索用户个人资料图片。
EN

Stack Overflow用户
提问于 2017-12-13 11:06:01
回答 0查看 1.1K关注 0票数 0

我有一个问题,试图检索存储在MYSQL数据库中的用户配置文件链接。

我尝试运行此代码来选择用户配置文件(存储用户配置文件图片链接的位置),但出现了500错误。

代码语言:javascript
复制
        <?php
    $stmt = $DB_con->prepare('SELECT id, userprofile FROM users ');
    $stmt->execute();
if($stmt->rowCount() > 0)
{
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        extract($row);
        ?>

​

​

链接存储在userprofile列中。

超文本标记语言(function.php包含数据库信息):

代码语言:javascript
复制
<?php 
    include('functions.php');


    if (!isAdmin()) {
        $_SESSION['msg'] = "You must log in first";
        header('location: ../login.php');
    }


?>

<!DOCTYPE html>
<html>
<head>
    <title> Admin Home</title>

</head>
<body>
    <div class="header">
        <h2>Admin - Home Page</h2>
    </div>
    <div class="content">
        <!-- notification message -->


        <!-- logged in user information -->
        <div class="profile_info">
            <img src="uploads/<?php echo $row['userprofile']; ?>" class="img-rounded" width="250px" height="250px" />

            <div>
                <?php  if (isset($_SESSION['user'])) : ?>
                    <strong><?php echo $_SESSION['user']['username']; ?></strong>

                    <small>
                        <i  style="color: #888;">(<?php echo ucfirst($_SESSION['user']['user_type']); ?>)</i> 
                        <br>
                        <a href="home.php?logout='1'" style="color: red;">logout</a>
                        &nbsp; <a href="create_user.php"> + add user</a>
                    </small>

                <?php endif ?>
            </div>
        </div>



    </div>

</body>
</html>

登录的测试用户的图像(Bigfella)

​

你知道为什么它不能从数据库中检索图像链接吗?提前感谢!!

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47784899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档