User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,480 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,825 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1224 | Replies: 2
Reply
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation: puddin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
puddin puddin is offline Offline
Junior Poster in Training

PHP Members HELP W/DB Images

  #1  
May 1st, 2006
Good Day, PHP Members HELP W/DB Images


I am desperately trying to allow the user to put selected images into the database and than view them in the photo gallery. If you know the method please tell me. I have tried for 3 days.

I have in my database table with all other member slots so to say (this)

short_title varchar = 50
mime_ type varchar = 50
file_data Binary = blob

Once the file goes in, it looks like this:
----------------------------
[BLOB - 9 Bytes]

And the short-title enters
-----------------------------

I cannot get the mime type to appear.
-----------------------------

My code looks like this:

<form "method="POST" action="photos.php" name="imagefrm" enctype="multipart/form-data">
<input type="file" name="file_data" size="20">&nbsp;
<br>
<input type="text" name="short_title" size="20"> Short Description
<br>
<input type="Submit" name="Submit" value="Upload">
<input type="HIDDEN" name="$session_name" value="$session_id">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</H3>
</form>

<p class="vp">
<form name="Photo Gallery "method="POST" action="photoview.php">
<input type="Submit" value="View">
<input type="HIDDEN" name="$session_name" value="$session_id">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</p>
</form>

<H3 class="pic">
<?php
include 'db.php';

// get the variables from home page
$password = $_SESSION['password'];
$email_address = $_SESSION['email_address'];

$sql_update = mysql_query("UPDATE myd SET file_data='file_date',
short_title='$short_title', mime_type='$mime_type' WHERE
email_address='$email_address' AND password='$password'");

$fileHandle = fopen($file_data, "r");
$fileContent = stripslashes($file_data);

// P.S I have used: fread() fscanf() and others all I get is errors!

$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){


echo ("Your pictures are not updated… try again");
} else {
echo ("Your pictures have been updated!");
}
?>
</H3>

<p class="picview">
<?echo '<img src="$file_data">';?>
</p>

THIS IS WHAT THE ERROR SHOWS – NOW THE PICTURE IS NOT ON MY SERVERS DIRECTORY BUT THE PICTURE IS IN THE MYSQL DATABASE…

CAN I RETRIEVE THE PICTURES FROM MYSQL DATABASE WITHOUT THEM BEING IN THE DIRECTORY? AND HOW – HOW DO I GET THE PHP TO DETEMINE THE FILE TYPE GIF, JPEG ETC… - HOW DO I STRIP THE C:\\ BLAH BLAH BLAH…

Again Your Help Is Much Appreciated, Thank-You Puddin

This Is What The Page Is Displaying No Picture Comes Up!

Photo Title: rock
File Type:
Photo Name: C:\\Documents and Settings\\LC\\My Documents\\My Pictures\\roadblock.gif


Pictures\\roadblock.gif): failed to open stream: No such file or directory in /storage/hostingfs/32/25432/puddinpatchdatematch.com/public/photos.php on line 229

Your pictures have been updated!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: PHP Members HELP W/DB Images

  #2  
May 2nd, 2006
There are a number of errors in your logic here. The first is that you are not storing the image in the database, just the local path name to it. I would suggest that you store your images in a directory, and a path to the image in the database.

You will actually need to upload the image to the server. Have a read up on the PHP functions move_uploaded_file, ImageCreateFromJpeg, and ImageCreateFromGif, which should give you most of the info you need to get started.
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Join Date: Aug 2006
Posts: 3
Reputation: darylcharm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
darylcharm darylcharm is offline Offline
Newbie Poster

Re: PHP Members HELP W/DB Images

  #3  
Aug 31st, 2006
hi i actually need this also. does anyone of you knows a good tutorial for a php gallery?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC