No output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tehquickness
Forum Commoner
Posts: 32
Joined: Mon Oct 24, 2005 11:31 pm

No output

Post by Tehquickness »

I have this code here. And I cant get any output. When i visit it in online, it just gives me a blank page.

Code: Select all

<?php
include("header.php");
$conn = include($_SERVER['DOCUMENT_ROOT']."/webadmin/library/openconndb.php");
print "test";


//START IMAGE DISPLAY
if(isset($_REQUEST['imgid'])){
  if(is_int($_REQUEST['imgid'])){
    $imgid = mysql_real_escape_string($_REQUEST['imgid']);
    $query = "select * from picture_database where id = '$imgid'";
    $result = mysql_query($query, $conn);
    $imgarray = mysql_fetch_assoc($result);
    print "<center>\n";
    print "<h2>".$imgarray['name']."</h2>\n";
    print "<img src=\uploaded\\".$imgarray['imagelocation']."\">";
    print "<br \>\n".$imgarray['description'];
  }
}
//END IMAGE DISPLAY



//START THUMBNAIL DISPLAY
if(isset($_REQUEST['catid']){
  if($_REQUEST['pageid']){
    $pageid = $_REQUEST['pageid'];
  }else{
    $pageid = 0;
  }
  if(!is_int($_REQUEST['catid'])){
    print "<center>Page error. Please try again.</center>";
  }else{
    $catid = mysql_real_escape_string($_REQUEST['catid']);
    $query = "select * from picture_categories where id='$catid'";
    $result = mysql_query($query, $conn);
    $catarray = mysql_fetch_array($result);
    print "<h2>Album: ".$catarray['name'];
    $query = "select * from picture_database where category_id = '$catid'";
    $result = mysql_query($query, $conn);
    
    if(mysql_num_rows($result)==0){
      print "There are no pictuers in this category."
    }else{
      $i = 0;
      while($pictureData = mysql_fetch_assoc($result);)){
        $picture_array[] = $pictureData;
      }
      while($i<= $count-1){
        $countarray[] = $picture_array[$i];
        $i++;
      }
      $row_chunks = array_chunk($countarray, 4);
      $page_chunks = array_chunk($row_chunks, 4);
      $i=0;
      print '<table width=100% border=1 cellspacing=0 cellpadding=10>';
      foreach($page_chunks[$pageid] as $rows){
          print '<tr>';
          $colcount = count($rows);
          print '<tr>';
          foreach($rows as $columns){
            print '<td width=25%><center>';
            print '<a href="pictures.php?imgid='.$columns['id'].'">'.'<img src="thumbnails/'.$columns['thumblocation'].'" border=0 />'
            print $columns['name']."</a><br />\n";
            print $columns['description']."<br />\n";
            print date('F j, Y', $columns['date'])."<br />\n";
            print '</center></td>';
          }
          switch($colcount){
           case 4:
             break;
           case 3:
             echo "<td width=25%>&nbsp;</td>\n";
             break;
           case 2:
             echo "<td width=25%>&nbsp;</td>\n";
             echo "<td width=25%>&nbsp;</td>\n";
             break;
           case 1:
             echo "<td width=25%>&nbsp;</td>\n";
             echo "<td width=25%>&nbsp;</td>\n";
             echo "<td width=25%>&nbsp;</td>\n";
             break;
          }
        print '</tr>';
      }
      print '</table>';
      $numberOfPages = count($page_chunks);
      $i = 0;
      print '<b>Pages: </b>';
      while($i <= $numberOfPages-1){
        print "<a href=\"pictures.php?catid=".$catid."&pageid=".$i."\">".($i+1)."</a>";
        $i++;
      }       
    }
  }
}


//END PICTURE DISPLAY



//START CATEGORY DISPLAY
if(!isset($_REQUEST['catid']) && !isset([$_REQUEST['imgid'])){
?>
  <h1>Choose A Picture Album</h1>
  <br>
<?php
  if($_REQUEST['pageid']){
    $pageid = $_REQUEST['pageid'];
  }else{
    $pageid = 0;
  }
  $query = "select * from picture_categories ORDER by id DESC";
  $result = mysql_query($query, $conn);
  if(mysql_num_rows($result) == 0){
?>
    <h2>No Categories have been created.</h2>
<?php
  }else{
    $count=mysql_num_rows($result);
    $i = 0;
    while($categoryinfo = mysql_fetch_array($result)){
      $category_array[] = $categoryinfo;
    }
    while($i <= $count-1){
      $countarray[]= $category_array[$i];
      $i++;
    }
    $row_chunks = array_chunk($countarray, 4);
    $page_chunks = array_chunk($row_chunks, 4);
    $i=0;
    print '<table width=100% border=1 cellspacing=0 cellpadding=10>';
    foreach($page_chunks[$pageid] as $rows){
      print '<tr>';
      $colcount = count($rows);
      foreach($rows as $columns){
        print '<td width=25%><center>';
        print '<a href="pictures.php?catid='.$columns['id'].'">'.$columns['name']."</a><br />\n";
        print $columns['description']."<br />\n";
        print date('F j, Y', $columns['date'])."<br />\n";
        print $columns['creator']."<br />\n";
        print '</center></td>';
      }
      switch($colcount){
        case 4:
          break;
        case 3:
          echo "<td width=25%>&nbsp;</td>\n";
          break;
        case 2:
          echo "<td width=25%>&nbsp;</td>\n";
          echo "<td width=25%>&nbsp;</td>\n";
          break;
        case 1:
          echo "<td width=25%>&nbsp;</td>\n";
          echo "<td width=25%>&nbsp;</td>\n";
          echo "<td width=25%>&nbsp;</td>\n";
          break;
        }
      print '</tr>';
    }
  print '</table>';
  $numberOfPages = count($page_chunks);
  $i = 0;
  print '<b>Pages: </b>';
  while($i <= $numberOfPages-1){
    print "<a href=\"pictures.php?pageid=".$i."\">".($i+1)."</a>";
    $i++;
  }
  }
?>
  <br><br>
  <center>
  <a href="addpicturecategory.php">Add a Category</a>
  </center>
<?php
}
//END CATEGORY DISPLAY

include("footer.php");
 
  ?>
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

right here..

Code: Select all

print '<a href="pictures.php?imgid='.$columns['id'].'">'.'<img src="thumbnails/'.$columns['thumblocation'].'" border=0 />'
            print $columns['name']."</a><br />\n";
            print $columns['descripti

Code: Select all

you missed a semi colon
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Just a suggestion, when testing your code, you may want to set error_reporting to E_ALL and turn on display_errors. That way you will get notified of any and all errors/warnings/notices that are cropping up in your app (and a pointer to the location of the fault) instead of just getting a blank page and trying figure where the heck it is.
Post Reply