View image from MySQL database
Posted: Mon Jan 10, 2011 11:38 pm
Here is my page code:
No matter what I do, I cannot get the picture (which has the path stored in a MySQL database) to show up. What do I do? Here is the table structure:
Code: Select all
<?php
/**
* UserInfo.php
*
* This page is for users to view their account information
* with a link added for them to edit the information.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 2, 2009 by Ivan Novak
*/
include("include/session.php");
$page = "profile.php";
?>
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>Tag Texter | Homepage</title>
<link rel="stylesheet" href="style.css" type="text/css" />>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<div id="content_top_topimage"></div>
<div id="content_top">
<?php
/* Requested Username error checking */
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
!eregi("^([0-9a-z])+$", $req_user) ||
!$database->usernameTaken($req_user)){
die("Username not registered");
}
/* Logged in user viewing own account */
if(strcmp($session->username,$req_user) == 0){
echo "<h1>My Account</h1><p>
<p>
<form name='newad' method='post' enctype='multipart/form-data' action='upload.php'>
<table>
<tr><td><input type='file' name='image'></td></tr>
<tr><td><input name='Submit' type='submit' value='Upload image'></td></tr>
<input type='hidden' name='username' value='$session->username' />
<br /><label>Profile?</label><input name='profile' type='checkbox' value='yes' checked>
</table>
</form>";
}
/* Visitor not viewing own account */
else{ ?>
<div id="profile_title">User Profile</div>
<?php
}
/* Display requested user information */
$req_user_info = $database->getUserInfo($req_user);
/* Name */
echo "<p><b>Name:</b> ".$req_user_info['name']."<br />";
/* Username */
echo "<p><b>Username:</b> ".$req_user_info['username']."<br />";
/**
* Note: when you add your own fields to the users table
* to hold more information, like homepage, location, etc.
* they can be easily accessed by the user info array.
*
* $session->user_info['location']; (for logged in users)
*
* ..and for this page,
*
* $req_user_info['location']; (for any user)
*/
/* If logged in user viewing own account, give link to edit */
if(strcmp($session->username,$req_user) == 0){
echo "[<a href=\"useredit.php\">Edit Account Information</a>]<br><br>";
}
/* Link back to main */
echo "[<a href=\"main.php\">Main</a>] ";
if($session->isAdmin()){
echo "[<a href=\"admin/admin.php\">Admin Center</a>] ";
}
?>
</div>
<div id="content_top_bottomimage"></div>
</body>
</html>Code: Select all
CREATE TABLE IF NOT EXISTS `uploads` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(30) NOT NULL,
`type` varchar(30) NOT NULL,
`size` int(11) NOT NULL,
`path` varchar(60) NOT NULL,
`username` varchar(100) NOT NULL,
`profile` varchar(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;