How to store Pictures in MYsql

Discussion in 'QnA (read only)' started by Butterfly, Oct 24, 2004.

Thread Status:
Not open for further replies.
  1. Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Folks ,

    How do i store pictures in MYSQL , plz give me step by step , as am very new to this Mysql.. so what i wanted to do is that , umm i wanted to store picture and description of the pic intodatabase and then show it in the form..

    i dont mind if u make one for me ..

    thanks a lot , will count on u all experts and intil;igent , as am so dull lol
     
  2. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    I am assuming you are using PHP/MYSQL

    as far as i know you cannot store images or anything into the database, you will have to store location of the image..

    your database structure can be like this..

    table pics..

    Code:
    CREATE TABLE `pics` (
      `id` int(11) NOT NULL auto_increment,
      `pic_title` varchar(100) NOT NULL default '',
      `pic_url` varchar(100) NOT NULL default '',
      `pic_description` text NOT NULL,
      PRIMARY KEY  (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=1 ;
    
    now to need to show these values into webpage..

    Code:
    <?php
    
    // Database connection strings
    $mysql_connect = mysql_connect($host,$username,$password) or die ("Sorry, I am not able to CONNECT to the Database");
    $mysql_select_db = mysql_select_db($mysql_db) or die ("Sorry, I am not able to SELECT the Database");
    
    // Database query
    
    $sql = "SELECT id,pic_title,pic_url,pic_description WHERE id = '$id'";
    $result = mysql_query($sql);
    
    // Start fetching the values from Database
    
    $row=mysql_fetch_array($result)
    
    $pic_title = $row[pic_title];
    $pic_url = $row[pic_url];
    $pic_description = $row[pic_description];
    ?>
    
    
    <form name="pic" action="pic-action.php" method="POST">
    
    
    
    <textarea name="description">
    <?php echo $pic_description; ?>
    
    
    
    </textarea>
    
    </form>
    
    that's it..

    i hope this helps you..
    Deep
     
  3. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Thanks a lot Deep

    Deep,

    Thank u so much for that , yeah surely i will try and use ur coding , i have never know that we cantont store pic into database , now i do ..it has to be given url to the pic right ..

    Once again thanks a lot ..
     
  4. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    no probs...

    yes u have to give url of pic in the table
    let me know if it doesnt work :)

    Deep
     
  5. xenkatesh

    xenkatesh Bewitched!

    Joined:
    Feb 7, 2004
    Messages:
    468
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    chennai
  6. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Hi Thanks

    Thanks a lot to yall, i will try and use it
     
Thread Status:
Not open for further replies.

Share This Page