php header warning weird!!

Discussion in 'PHP' started by Dangy, Mar 21, 2012.

  1. #1
    Can't seem to explain this.

    http://clickadx.com/image.php?id=2

    Warning: Cannot modify header information - headers already sent by (output started at /home/clickadx/public_html/include/middle.php:36) in /home/clickadx/public_html/image.php on line 12

    code for the image.php page

    <?
    include('include/function.php');
    connect();
    $id = $_GET['id'];
    $query = "SELECT * FROM images WHERE id='$id' LIMIT 1";
    $image_type = $_GET['img'];
    $result = mysql_query($query);
    if($row = mysql_fetch_array($result)){
    $imageData = $row['image'];
    $imageType = $row['type'];
    }
    header("Content-type: $imageType");
    echo $imageData;
    ?>

    thats it never even calls the middle.php page
     
    Dangy, Mar 21, 2012 IP
  2. Devitor

    Devitor Peon

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    0
    #2
    if you are trying to display your image i suggest you change the echo line to

    switch ($imageType) { 
    			case "image/gif": 
    				imagegif($imageData); 
    				break; 
    			case "image/jpeg": 
    				imagejpeg($imageData);
    				break; 
    			case "image/png": 
    				imagepng($imageData);
    				break; 
    		} 
    Code (markup):
    as to the header error, you will need to double check all your code to make sure that you are sending everything in the right order, and not sending 2 headers.
     
    Devitor, Mar 21, 2012 IP
  3. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #3
    I'm willing to bet that somewhere include/function.php is calling middle.php (either directly or indirectly).

    Also, you should get out of the habit of using short tags.
     
    Alex Roxon, Mar 21, 2012 IP
  4. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    #4
    that image type is stored in the database so your method would be extra coding not needed.
     
    Dangy, Mar 22, 2012 IP
  5. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    #5
    It was working perfectly, an I have not even touch the coding in awhile.. nothing has changed since it was working. An the function.php does not call the middle.php never. Middle.php is a template file. An on the line it states where the error in the middle.php is not a header being called at all.
     
    Dangy, Mar 22, 2012 IP
  6. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #6
    Can you paste lines 30-40 of middle.php? Also, is there an error_log file in the directory with recent entries?
     
    zacharooni, Mar 22, 2012 IP
  7. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    #7
        </div>
        <a href="/">Lost Pass?</a>
          <input type="submit" name="login" class="login-b" value="Login" />
    </form>
    <?}}?>
    
    <?if($page =='members'){?>
    		<div class="fst">
    			<span>Credits: 902</span>
    				<span style="float:right;">Referral Link: http://clickadx.com/index.php?page=register&ref=username</span>
    		</div>
    Code (markup):
    this is line 30-40 of middle.php an the error they say errors on line 36. which is <?if($page =='members'){?>

    EDIT: Fixed the problem, there was a bracket not closed in the function.php
     
    Last edited: Mar 22, 2012
    Dangy, Mar 22, 2012 IP