Warning: Cannot modify header information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dfm
    New Member
    • Feb 2008
    • 6

    #16
    I tried that, its displaying a picture box with a red x in it and the funny characters next to it ?

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #17
      Originally posted by dfm
      I tried that, its displaying a picture box with a red x in it and the funny characters next to it ?
      If the data has the path to the image in it and this is where the image then is it should show just fine. Perhaps the image isn't wwhere the database says it is?

      Did you place any alt text in the image text? This should display if the image can't be found.

      Double check the file path of the image and check this path in relation to the path of the code being executed.

      If you are just using jpg and <img> tags then the header is not strictly necessary as far as I am aware.

      Cheers
      nathj

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #18
        Originally posted by dfm
        I tried that, its displaying a picture box with a red x in it and the funny characters next to it ?

        What were you actually trying to get by using that header?..
        Also post the HTML generated by that part of the code here.

        Comment

        • dfm
          New Member
          • Feb 2008
          • 6

          #19
          [HTML]«åO;½kã2ßÍ:ÿ— S
          ™8® §‡|¹}yá 5¸¹æ¶‡½õ
          ¬{w,0ÅpÅ?‚ÿ>Ϋï ËÅq$XÉQ|¢àoex
          kžk`y(¤¢±_ ˜\{çN]_p䂦«Š&ÿŸµã
          /¿'ZÕ±æ¶
          ßÌ=»Õáf ûCû}oã—Óˆi©À YvÁ
          ©a)a)a)a)a )a)a)a)a)a 
          )a)a)a)a+åØ ”9øgÅ,ÒI<ðŽ«Ïs
          à—Sµ>5LÔÝéÛÆo nNµ=RÑSÕ
          =QÕ=QÕNî9-¸ã%.8ÉKŽ2
          R㌔¸ã%.8ÉKŽ2Rã
          Œ”¸ã%.8ÉKŽ2R㌔ ¸ã%.8ÉKŽ2W
          ä]díuý^?õ†t:ü»:§ ¿*¼ÊЍ¹*y5G òÀ…,
          RÀ…,RÀ…Kn¹Ÿ.Ô ºã%.¸ÉK®2R
          댔ºã%.¸É
          K®2R댔ºã%.¸ÉK® 2R댔ºã%.¸
          ÉK®2Q{ˆ©‚®C%F=ó «éMyø³„—öD
          ú>}þ8ûñưuŠRÈ RÈRÈRÈW~ûœ²¾ ‹î2h¾
          ã&‹î2h¾ã&‹î2h¾ã &‹î2h¾ã&‹î2h ¾
          ã&‹î2h¾ã&‹î2h¾ã &‹î2h¾ã&˜òv¡É„ ó
          Šùõ*7î\Rëò,£Ÿ ø;úùröhÙrùE,¸ÉK
          .2RËŒ•Ò¾årÜdÑ }ÆJ_q“E÷)}
          ÆMÜd¥÷)}ÆJ_q’ —ÜdÑ}ÆJ_q’—
          Üd¥÷)}ÆJ_q’—Üd ¬9;PäŠÆy¢“ÏTW
          ¹ qKòŽpS§ëVË–Ê)i ÆJZq’º9îЄ™îÐ
          €Ïv€3Ý ÷h=ÚÏv„†{´ 3Ý¡!žíg»B=ÚÏv
          €3Ý¡!žíg»B=ÚÏv €3Ý sšùÿ¯ðqy
          ?ºá§NŠ1ÍÉ ÜÿÙ"> [/HTML]

          I have a mysql database to which I uploaded an image not a the path to an image but the actual image. When using a test.php file to display it displays the image fine. It gave me the same error when I used a function.php with the connection string, so I deleted it and put the connection string in the actual page and it worked. But now on the actual page I need to use it , it doesnt want to display?
          Last edited by ronverdonk; Mar 3 '08, 11:21 AM. Reason: code too wide

          Comment

          • dfm
            New Member
            • Feb 2008
            • 6

            #20
            meant put the connection string in the test page, sorry

            Comment

            • nathj
              Recognized Expert Contributor
              • May 2007
              • 937

              #21
              Why not just have the path to the image stored in the database and then use that information in a normal <img> tag?

              This would be much simpler and not require headers.

              Cheers
              nathj

              Comment

              • hsriat
                Recognized Expert Top Contributor
                • Jan 2008
                • 1653

                #22
                For that you would need to make another PHP file. Say get_image.php with the following code:[php]<php
                if (!isset($_GET['id'])) die('Invalid Parameter');
                /*
                DO - CONNECT TO DATABASE
                FETCH ARRAY FROM THE DB, WHERE unique_id_of_th e_table = $_GET['id']
                */
                header("Content-type: image/jpeg");
                echo $rows['image'];
                ?>[/php]
                And edit line no. 71 of your above file like this:
                [html]<th scope="col"><im g src="get_image. php?id=<? echo $rows['unique_id_of_t he_table']; ?>"></img></th>[/html]

                * unique_id_of_th e_table : whatever unique id you are using.

                Comment

                • nathj
                  Recognized Expert Contributor
                  • May 2007
                  • 937

                  #23
                  Maybe I'm missing something, and I'm perfectly happy to admit that, but is the point of putting the image itself into the database? Surely it is easier to just put the image as a file on the server somewhere and then put the file path in the database. This can then be used in a nomal <img> tag without any need for faffing around with headers.

                  It just seems to make more sense to me that way. Obviously you can't set the src of the img to be the actual image which is why it didn't work earlier.

                  If it were me I would have fields in the table called image_src, image_title and image_alt. Then assuming the SQL had been run and the following code is inside a foreach loop:
                  [php]
                  echo "<img src='" . $laRow['image_src'] . "' title='" . $laRow['image_title'] . "' alt='" . $laRow['image_alt'] ."' />' ;
                  [/php]

                  I am aware that this is a small code snippet, I would have this in a foreach loop after the SQL returned an associative array. I use this type of structure a lot and it works everytime.

                  Cheers
                  nathj

                  Comment

                  Working...