Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: how to display multiple blob images from mysql : mysql, php

  1. #1
    Join Date
    Jan 2007
    Posts
    197
    Rep Power
    0

    Default how to display multiple blob images from mysql : mysql, php

    i want to display all images stored in mysql database but it is displaying small crosses in place of image. here is my code. please help me.

  2. #2
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default

    I think I see what the problem is. There is absolutely no code in your post!

    Try writing some code to retrieve the image from the database. Can refer to the MySQL manual for assistance. http://dev.mysql.com/doc/refman/5.1/en/index.html

  3. #3
    Join Date
    Jan 2007
    Posts
    197
    Rep Power
    0

    Default

    I got it to work this morning thx 4 the reply though. Did some searching and figured out that the content type i waz using waz not image
    <?php
    $username = "user";
    $password = "password";
    $host = "localhost";
    $database = "database";

    @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

    @mysql_select_db($database) or die("Can not select the database: ".mysql_error());

    $id = $_GET['id'];

    if(!isset($id) || empty($id)){
    die("Please select your image!");
    }else{

    $query = mysql_query("SELECT * FROM restaurants WHERE restid='".$id."'");
    $row = mysql_fetch_array($query);
    $logo = $row['logo'];

    header('Content-type: image/jpg');
    echo $logo;

    }
    ?>
    Last edited by thuggest_1; Mar 17, 2009 at 10:19 AM.

  4. #4
    Join Date
    Nov 2004
    Posts
    200
    Rep Power
    0

    Default

    Quote Originally Posted by thuggest_1 View Post
    I got it to work this morning thx 4 the reply though. Did some searching and figured out that the content type i waz using waz not image
    you should read about SQL Injection before using that code

  5. #5
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default

    Quote Originally Posted by engineroom View Post
    you should read about SQL Injection before using that code
    Indeed. Anyone can use the ID he is using in his SQL statement and break into his database. (break isn't the right word is it?)

  6. #6
    Join Date
    Nov 2004
    Posts
    200
    Rep Power
    0

    Default

    Quote Originally Posted by Arch_Angel View Post
    Indeed. Anyone can use the ID he is using in his SQL statement and break into his database. (break isn't the right word is it?)
    yes or worse "?id=1;drop table restaurants;"

  7. #7
    Join Date
    Jan 2007
    Posts
    197
    Rep Power
    0

    Default

    oh dear....thx 4 da heads up guys....wat would be safer 2 use....plz 2 send me bac 2 guh read

  8. #8
    Join Date
    Feb 2006
    Posts
    4,242
    Rep Power
    0

    Default

    Quote Originally Posted by thuggest_1 View Post
    I got it to work this morning thx 4 the reply though. Did some searching and figured out that the content type i waz using waz not image
    Yow edit your post asap;
    example
    PHP Code:
    <?php
    $username 
    "user";
    $password "password";
    $host "localhost";
    $database "database";
    ?>
    |--- www.RealJamaicaEstate.com ™ ---|
    Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
    --- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com

  9. #9
    Join Date
    Jan 2007
    Posts
    197
    Rep Power
    0

    Default

    thx. Didnt even realize the mistake

  10. #10
    digimon Guest

    Default

    It's strange, i did this in ASP.NET 2 days ago. It's the same thing but diff language

Posting Permissions

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