Code Problem

  • bluedragon
  • Proficient
  • Proficient
  • bluedragon
  • Posts: 452

Post 3+ Months Ago

I have this code to display an uploaded image. Although I need it to display it with my theme around it. Here is how the directory with the theme works.

root-
images.php
header.php
footer.php

theme-
/skin/default/header.html
/skin/default/footer.html

Here is the code from images.php.

PHP Code: [ Select ]
<?
 
define('IN_OUTPUT',1);
include "includes/inc.php";
/**
* get var from url or query
*/
if(!empty($input[t]))
{
    $type='t';
    $id=intval($input[t]);
}
elseif(!empty($input[i]))
{
    $type='i';
    $id=intval($input[i]);
}
elseif(!empty($input[m]))
{
    $type='m';
    $id=intval($input[m]);
}
else
{
    $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
    $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
    $last=strrpos($path,'/');
    $type=substr($path,$last+1,1);
    $id=intval(substr($path,$last+2));
}
$db->setQuery("select
              i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
              ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
              from images4g as i
              left join gallery as gal on gal.gallery_id=i.gallery_id
              left join users as u on u.id=gal.uid
              left join groups as g on g.id=u.gid
              where i.id='$id'");
$db->query();
$row=$db->loadRow();
processOutput($row,$type);
?>
  1. <?
  2.  
  3. define('IN_OUTPUT',1);
  4. include "includes/inc.php";
  5. /**
  6. * get var from url or query
  7. */
  8. if(!empty($input[t]))
  9. {
  10.     $type='t';
  11.     $id=intval($input[t]);
  12. }
  13. elseif(!empty($input[i]))
  14. {
  15.     $type='i';
  16.     $id=intval($input[i]);
  17. }
  18. elseif(!empty($input[m]))
  19. {
  20.     $type='m';
  21.     $id=intval($input[m]);
  22. }
  23. else
  24. {
  25.     $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
  26.     $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
  27.     $last=strrpos($path,'/');
  28.     $type=substr($path,$last+1,1);
  29.     $id=intval(substr($path,$last+2));
  30. }
  31. $db->setQuery("select
  32.               i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
  33.               ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
  34.               from images4g as i
  35.               left join gallery as gal on gal.gallery_id=i.gallery_id
  36.               left join users as u on u.id=gal.uid
  37.               left join groups as g on g.id=u.gid
  38.               where i.id='$id'");
  39. $db->query();
  40. $row=$db->loadRow();
  41. processOutput($row,$type);
  42. ?>


Now I tried adding these into there where in the header.php and footer.php files just pull the information from the theme files.

PHP Code: [ Select ]
<?
 
define('IN_OUTPUT',1);
include "includes/inc.php";
include "header.php";
/**
* get var from url or query
*/
if(!empty($input[t]))
{
    $type='t';
    $id=intval($input[t]);
}
elseif(!empty($input[i]))
{
    $type='i';
    $id=intval($input[i]);
}
elseif(!empty($input[m]))
{
    $type='m';
    $id=intval($input[m]);
}
else
{
    $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
    $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
    $last=strrpos($path,'/');
    $type=substr($path,$last+1,1);
    $id=intval(substr($path,$last+2));
}
$db->setQuery("select
              i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
              ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
              from images4g as i
              left join gallery as gal on gal.gallery_id=i.gallery_id
              left join users as u on u.id=gal.uid
              left join groups as g on g.id=u.gid
              where i.id='$id'");
$db->query();
$row=$db->loadRow();
processOutput($row,$type);
include "footer.php";
?>
  1. <?
  2.  
  3. define('IN_OUTPUT',1);
  4. include "includes/inc.php";
  5. include "header.php";
  6. /**
  7. * get var from url or query
  8. */
  9. if(!empty($input[t]))
  10. {
  11.     $type='t';
  12.     $id=intval($input[t]);
  13. }
  14. elseif(!empty($input[i]))
  15. {
  16.     $type='i';
  17.     $id=intval($input[i]);
  18. }
  19. elseif(!empty($input[m]))
  20. {
  21.     $type='m';
  22.     $id=intval($input[m]);
  23. }
  24. else
  25. {
  26.     $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
  27.     $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
  28.     $last=strrpos($path,'/');
  29.     $type=substr($path,$last+1,1);
  30.     $id=intval(substr($path,$last+2));
  31. }
  32. $db->setQuery("select
  33.               i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
  34.               ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
  35.               from images4g as i
  36.               left join gallery as gal on gal.gallery_id=i.gallery_id
  37.               left join users as u on u.id=gal.uid
  38.               left join groups as g on g.id=u.gid
  39.               where i.id='$id'");
  40. $db->query();
  41. $row=$db->loadRow();
  42. processOutput($row,$type);
  43. include "footer.php";
  44. ?>


Only problem is that when I do that the image doesn't display. The header shows, the footer doesnt. The image is displayed at code as if you opened the image with notepad.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Does the image not show at all? Or is there an X where its not loading?
  • bluedragon
  • Proficient
  • Proficient
  • bluedragon
  • Posts: 452

Post 3+ Months Ago

Nevermind. I got it fixed. Missed a ; in the code. Thanks.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 133 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.