Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    4

    Unanswered: 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.

  2. #2
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    10
    Whats your querry ($get)?
    [/.. Höre alles, glaube wenig, sage nichts ..\]

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    4

    $get=

    Code:
    $get = mysql_get_assoc( mysql_query(" select `TYPE`, `DATA` from articles where id = $id") );

  4. #4
    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)?

  5. #5
    Join Date
    Dec 2003
    Posts
    56
    Maybe this tutorial can help you along....

    http://codewalkers.com/tutorials/35/1.html

  6. #6
    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 ...
    Last edited by princes; 11-26-04 at 09:07. Reason: url
    [/.. Höre alles, glaube wenig, sage nichts ..\]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •