Closed Thread
Page 8 of 22 FirstFirst ... 67891018 ... LastLast
Results 71 to 80 of 214

Thread: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

  1. #71
    poeticparadox is offline Newbie
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Jaan,

    I have been working through your tutorial but I have missed something as the output is still coming out in code rather then the image. Example: studiosgroup.co.uk/don/viewimg.php?imgid=001. Thanks for you help

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #72
    Jaan Guest

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Hmm well your ID can't be like that.. ?imgid=001 it must be and it is ?imgid=1 because this ID is automatically generated..

  4. #73
    poeticparadox is offline Newbie
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    This is the code that I am using to insert the image into the database:
    Code:
    <?php
    // Create MySQL login values and 
    // set them to your login information.

      
    include "includes/functions.php";
      include 
    "includes/config.php";
      require_once 
    "includes/db.php";
     

    // Make the connect to MySQL or die
    // and display an error.
     
      
    $d = new dbC();
      
    $d->connect($db_host$db_user$db_pass$db);

    if (!
    $d) {
        die(
    'Could not connect: ' mysql_error());
    }

    // Select your database
    //mysql_select_db ($database); 

    // Make sure the user actually 
    // selected and uploaded a file
    if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

          
    // Temporary file name stored on the server
          
    $tmpName  $_FILES['image']['tmp_name'];  
           
          
    // Read the file 
          
    $fp      fopen($tmpName'r');
          
    $data fread($fpfilesize($tmpName));
          
    $data addslashes($data);
          
    fclose($fp);
          

          
    // Create the query and insert
          // into our database.
          
    $query "INSERT INTO tbl_images ";
          
    $query .= "(image, Memberno) VALUES ('$data','$_POST[memberno]')";
          
    $results mysql_query($query);
          
          
    // Print results
          
    print "Thank you, your file has been uploaded.";
          echo 
    $empid;
          
    }else{
       print 
    "No image selected/uploaded";
    }

    // Close our MySQL Link
    $d->close();
    ?>
    As you can see I am calling an empid so that I can preform a one to many relationship with tbl_Emp and tbl_images (for example) I am then passing the empid to the veiwimg.php to call up all the images for that emp. Make sence?
    Last edited by WingedPanther; 06-10-2009 at 11:28 AM. Reason: add code tags (the PHP sheet)

  5. #74
    kipper is offline Newbie
    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Hi, thanks a lot for your tutorial!

    May i ask if i can display a picture of students on excursion with comments from teachers, parents and fellow students, with all pictures and comments stored in a database. All the information is on the same page, something like a report.

    Thanks a lot in advance,
    Lee

  6. #75
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Quote Originally Posted by kipper View Post
    Hi, thanks a lot for your tutorial!

    May i ask if i can display a picture of students on excursion with comments from teachers, parents and fellow students, with all pictures and comments stored in a database. All the information is on the same page, something like a report.

    Thanks a lot in advance,
    Lee
    Its very possible. You can add a few more rows to the database to make this happen. If you want you could always hire me to do this for you. Email me for a quote.

  7. #76
    shamoco is offline Newbie
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    good code

  8. #77
    phpuser is offline Newbie
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Hi,

    I have been following the forum. I tried display image. It worked. Thanks!
    I have question on that. How do we set the image size to display?

  9. #78
    Jaan Guest

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    well.. this script displays you the full image.. if you use other GD functions then you can resize this picture if you want..

  10. #79
    Jan
    Jan is offline Newbie
    Join Date
    Jul 2009
    Posts
    7
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    Hi,

    Apparently many people get this to work but after days of trying all different kinds of scripts I still can seem to get a picture showing on my page.
    I have copied your tutorial exactly but the best so far was when I got a pop-up asking me if I wanted to download the picture.
    How can I actually get this picture in a web page, i.e. how do I call it?
    Thanks, I'd appreciate any help..

  11. #80
    Jaan Guest

    Re: Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

    well.. you display it like this

    HTML Code:
    <img src="image.php?id=1" />

Closed Thread
Page 8 of 22 FirstFirst ... 67891018 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Similar Threads

  1. Replies: 3
    Last Post: 02-07-2011, 11:29 AM
  2. Tutorial: Storing Images in MySQL with PHP
    By Jordan in forum PHP Tutorials
    Replies: 47
    Last Post: 01-04-2011, 08:37 PM
  3. Beginner Storing images in XML file - Part II - Displaying image
    By Jaan in forum PHP Tutorials
    Replies: 6
    Last Post: 01-04-2011, 08:35 PM
  4. display images sequentially using PHP and MySQL
    By jhanjon in forum PHP Development
    Replies: 2
    Last Post: 10-08-2009, 12:11 PM
  5. Replies: 2
    Last Post: 07-16-2009, 12:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

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