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

Thread: php

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy php

    I want to save the pictures (jpg files) in the database and i want to view that pictures using php. please help me. what is the code for that?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's exactly the same as reading/writing anything else to/from a database. Make sure, though, that the row/column* you're writing it into allows binary input. In MySQL, this means it needs to be of the BLOB type with its BINARY attribute set.
    Then, just store/retrieve it normally, and use a header("Content-Type: image/jpeg"); statement to set the MIME-type correctly before echoing the data to the browser.

    * preferred visualisation varies depending on database package.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    not to drag this off topic, but a quick question about the MIME-type command...

    I saw that as an example for a page that was a php-generated image... and it's url was .../image.php, but it was just like a .jpg viewed as its own page.

    Would you still need to include the MIME-type command if you were using the image in a page, such as the <img ...> command?

    I might be missing something.

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    I saw that as an example for a page that was a php-generated image... and it's url was .../image.php, but it was just like a .jpg viewed as its own page.

    Would you still need to include the MIME-type command if you were using the image in a page, such as the <img ...> command?
    Yes. The user agent will (or at least should) depend upon the Content-Type HTTP header to determine how to handle a file. An accurate Content-Type header should be sent with every HTTP response that contains an entity body (returned content).

    Mike

  5. #5
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy php

    I solved that problem.
    Another problem If I clike a button i want to view the data in another page.
    (only using php)

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Huh? Not too clear.

    <form action='OTHERPAGE'>
    <input type='submit'>
    </form>

    That would work. Put it inside an echo tag if you need it to be displayed by php.

    ...
    echo "[insert above code]";
    ...

  7. #7
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face php

    code is ok. But i want to pass a value to other page.
    eg:- ______ search.
    here i want to give a value (eg: name) for search & view the details of that data(eg:- age, firstname, lastname, etc...) another page using php.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <form action='OTHERPAGE' method="post">
      <input type="text" name="search">
      <input type='submit' value="Search">
    </form>
    On the PHP page, retrieve the value using
    PHP Code:
    $_POST['search'
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy php

    I want to insert a picture inside the php code.
    echo(" <tr> <td height=\"17\"><img src=\"a.jpg\" width=\"748\" height=\"20\"></td> </tr>");
    is it correct?
    But it is not working. why?

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You don't insert a picture into PHP code; you cause PHP to output the HTML to display the picture.
    That is correct. Is the code being called?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •