If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > images in SQL database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-04, 09:13
Nanaki Nanaki is offline
Registered User
 
Join Date: Nov 2004
Location: Norway
Posts: 4
images in SQL database

Hey.
I'm a beginner with php/MySQL, but I'm eager to learn and have started on a project to learn. I try to do practical things, things that I might use on a website (hobby).

The project is to make a system for adding articles to a site. I’ve made a form that allows me to write a full article for a webpage. (header, introduction, body copy.. aso) The form also includes an upload of a picture, which is stored in the SQL database. ( as a blob)

The problem comes when I want to get this full article out to a web page again; I manage to get all writings (text), but not the pictures. In phpMyAdmin I see that the pics are successfully uploaded to the DB.

Let's call the database "articles", and it includes:
Code:
id
navn // name on the one's inputting data
dato //date the data is inputted
header // heading on the article 
ingress // introduction
innlegg // body copy
bildetekst // text for under picture
name //name on file eks: portrett.jpg
TYPE // image/jpg image/gif aso
DATA //images file stored in a mediumblob
I use this code to output my content:
Code:
while ($rad = mysql_fetch_array($get))
{

$id = $rad["id"];
$navn = $rad["navn"];
$dato = $rad["dato"];
$header = $rad["header"];
$ingress = $rad["ingress"];
$innlegg = $rad["innlegg"];
$bildetekst = $rad["bildetekst"];
$name = $rad["name"]; // name of file, like porteret.jpg shall be used as alt trext: alt="$name" 

echo "<h2>".$header."</h2>\n";
echo "<h3>".$ingress."</h3>\n";
echo "<p>".$innlegg."</p>\n";
echo "<p>".$bildetekst."</p>\n";
echo "<img src=\"image.php?id=$id\" alt=\"$name\" width=100 align=center>\n";
//the line above does not work, and that's the problem.

echo "<p class=\"author\">Updated by: $navn $dato</p>\n<hr>\n";
All help is appreciated.
Reply With Quote
  #2 (permalink)  
Old 11-24-04, 10:13
princes princes is offline
Registered User
 
Join Date: Oct 2004
Location: Germany
Posts: 10
Whats your querry ($get)?
__________________
[/.. Höre alles, glaube wenig, sage nichts ..\]
Reply With Quote
  #3 (permalink)  
Old 11-24-04, 10:19
Nanaki Nanaki is offline
Registered User
 
Join Date: Nov 2004
Location: Norway
Posts: 4
$get=

Code:
$get = mysql_get_assoc( mysql_query(" select `TYPE`, `DATA` from articles where id = $id") );
Reply With Quote
  #4 (permalink)  
Old 11-25-04, 08:24
Nanaki Nanaki is offline
Registered User
 
Join Date: Nov 2004
Location: Norway
Posts: 4
reformulate..

Ok, I'll try to formulate myself another way:
How can I get content from a MySQL database into a webpage, if the content in the database is both text and picture(s)?
Reply With Quote
  #5 (permalink)  
Old 11-25-04, 10:55
TimoV TimoV is offline
Registered User
 
Join Date: Dec 2003
Posts: 56
Maybe this tutorial can help you along....

http://codewalkers.com/tutorials/35/1.html
Reply With Quote
  #6 (permalink)  
Old 11-26-04, 08:03
princes princes is offline
Registered User
 
Join Date: Oct 2004
Location: Germany
Posts: 10
Lightbulb

does your file work without the text ? what error message do you get ?
maybe try that tutorial, there is a nother way ...
__________________
[/.. Höre alles, glaube wenig, sage nichts ..\]

Last edited by princes; 11-26-04 at 08:07. Reason: url
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On