Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using include - works/doesn't work - See Example

    OK, this should be simple,
    but makes ZERO sense to me.

    I am going to link you to identical files with different names.

    One works and one doesn't.

    http://pixelsfortroops.com/index-menu.php
    This file: index-menu.php - Works

    http://pixelsfortroops.com/index.php
    This file: index.php - Does not Work

    Does this ring a bell to anyone?


    menu.html sets a cookie that expire immediately for testing purposes.
    The window with the yellow border should disappear in 3 seconds.


    Thank you for any light you can shed on this.

    Dan
    Attached Files Attached Files
    Last edited by scuba_; 08-15-2008 at 03:35 PM. Reason: changed title, added file attachment

  • #2
    New Coder
    Join Date
    Aug 2008
    Posts
    64
    Thanks
    11
    Thanked 0 Times in 0 Posts
    I might can help but post the script in php tags on the post itself not in file form

  • #3
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    It's probably this
    PHP Code:
    if (!empty($grids))
          
    $row[] = array_shift($grids);
      } 
    You're missing the opening curly brace to your if statement
    EDIT
    Though now that I look at it again it looks like you're if statement should be like this if you don't want to use braces
    PHP Code:
    if (!empty($grids)) $row[] = array_shift($grids); 
    This is on line 86 by the way
    Last edited by ninnypants; 08-15-2008 at 03:44 AM.

  • #4
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm .. but what would this have to do with the file name?

    examples:
    • index.html or
    • index-menu.php or
    • *.php


    I don't see why it works PERFECT when named index-menu.php, and does not work at all when names index.php

    Should I explain this differently?
    Is it because it is the directory index that it loads differently?


    Quote Originally Posted by ninnypants View Post
    It's probably this
    PHP Code:
    if (!empty($grids))
          
    $row[] = array_shift($grids);
      } 
    You're missing the opening curly brace to your if statement
    EDIT
    Though now that I look at it again it looks like you're if statement should be like this if you don't want to use braces
    PHP Code:
    if (!empty($grids)) $row[] = array_shift($grids); 
    This is on line 86 by the way

  • #5
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php 

    //init variable for cache 
    if (isset($_REQUEST['grid']))
        
    $grid = (int)$_REQUEST['grid'];
    else 
        
    $grid 1;

    require_once(
    'config.php');
    require_once(
    'grid.class.php');
    //clean cache init
    unset($grid);

    // handle magnifier toggle
    if (isset($_REQUEST['magnify'])) {
        
    $_SESSION['magnify'] = !empty($_REQUEST['magnify']);
      
    $args = array();
      if (@
    $_REQUEST['grid'] > 1)
        
    $args['grid'] = $_REQUEST['grid'];
      
    $app->redirect(false$args);
    } else {
        if (isset(
    $_REQUEST['grid']))
            
    $grid = (int)$_REQUEST['grid'];
        else
            
    $grid 1;
    }

    // handle clickthrough
    if (isset($_REQUEST['r'])) {
      require_once(
    'region.class.php');
      
    $tbl = new Region;
      
    $region $tbl->get($_REQUEST['r'], false);
      if (
    is_null($region->id()) || $region->status != REGION_ACTIVE)
        
    $app->redirect();

      if (empty(
    $_SESSION['user_id']) && empty($_SESSION['is_admin'])) {
        
    $region->clicks++;
        
    $region->save();
        
    $smarty->clear_all_cache(null'index|search');
      }

      
    header("Location: " $region->url);
      exit;
    }

    // process any region expiration events
    require_once('util.class.php');
    Util::process_expired_regions();

    // fetch all the grids
    $tbl = new Grid;
    $grids $tbl->find_all('order by display_order');

    // make sure grid columns are >= 1
    $c max(1$app->setting->grid_columns);

    // if multiple grid pages are used, build links to the other pages, and then
    // get only the requested grid
    if ($app->setting->multiple_grid_pages) {
      require_once(
    'snippet.class.php');
      
    $g =& $_REQUEST['grid'];
      
    $g max(1$g);
      
    $g min(count($grids), $g);
        
    $links = array();
      for (
    $i 0$i count($grids); $i++) {
        
    $title htmlspecialchars(Snippet::snippet_text('grid_title'$grids[$i]->id'##Pixels##'));
        if (
    $i == $g 1)
          
    $links[] = '<strong>' $title '</strong>';
        else {
          
    $params = array();
          if (
    $i 0)
            
    $params = array('grid' => $i 1);
          
    $links[] = '<a href="' htmlspecialchars($app->url(false$params)) . '">' $title '</a>';
        }
      }
      
    $smarty->assign('links'$links);
      
    $grids = array($grids[$g 1]);
      
    $c 1;
    }

    // arrange grids into rows/columns
    $rows = array();
    while (!empty(
    $grids)) {
      
    $row = array();
      for (
    $i 0$i $c$i++) {
        if (!empty(
    $grids))
          
    $row[] = array_shift($grids);
      }
      
    $rows[] = $row;
    }

    //get region ids for every grid 
    $rids_ids $db->getCol('SELECT * FROM '.DB_PREFIX.'regions''id');
    //$rids_ids
    $smarty->assign('rids_ids'$rids_ids);
    $smarty->assign('rows'$rows);
    $smarty->display('index.tpl''index|'.(int)$_SESSION['magnify'].'|'.(int)$grid.'|'.$cache_id);
    include(
    'menu.html');
    ?>
    It is in the last line where i use the "include" function

    Quote Originally Posted by westes View Post
    I might can help but post the script in php tags on the post itself not in file form

  • #6
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    RESOLVED:

    I don't know why, but I eliminated the "Magnify" feature and it works like a champ. I didn't love that anyway, so now i'm good to go.

    cheers and goodnight

    dan

  • #7
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought it was, but it is not RESOLVED.

    This is such a SILLY thing to be happening.

    Please read my top post.

    Thank you,
    Dan

  • #8
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    You're still missing multiple curly braces"{" in this section
    PHP Code:
    if ($i == $g 1)
          
    $links[] = '<strong>' $title '</strong>';
        else {
          
    $params = array();
          if (
    $i 0)
            
    $params = array('grid' => $i 1);
          
    $links[] = '<a href="' htmlspecialchars($app->url(false$params)) . '">' $title '</a>';
        } 
    Should be
    PHP Code:
    if ($i == $g 1){
          
    $links[] = '<strong>' $title '</strong>';
        }else {
          
    $params = array();
          if (
    $i 0){
            
    $params = array('grid' => $i 1);
          
    $links[] = '<a href="' htmlspecialchars($app->url(false$params)) . '">' $title '</a>';
          }
        } 

  • #9
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ninnypants View Post
    You're still missing multiple curly braces"{" in this section
    PHP Code:
    if ($i == $g 1)
          
    $links[] = '<strong>' $title '</strong>';
        else {
          
    $params = array();
          if (
    $i 0)
            
    $params = array('grid' => $i 1);
          
    $links[] = '<a href="' htmlspecialchars($app->url(false$params)) . '">' $title '</a>';
        } 
    Should be
    PHP Code:
    if ($i == $g 1){
          
    $links[] = '<strong>' $title '</strong>';
        }else {
          
    $params = array();
          if (
    $i 0){
            
    $params = array('grid' => $i 1);
          
    $links[] = '<a href="' htmlspecialchars($app->url(false$params)) . '">' $title '</a>';
          }
        } 
    I tried your suggestion .. that created a TON of errors.
    I'll leave the script alone, it works fine the way is it.
    Thanks anyway :-)






    Can anyone explain why the file name would have anything to do with this file including or not including the menu.html file?


    PHP Code:
    <?php
    ...
    include(
    'menu.html');
    ?>

  • #10
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm impressed, I stumped a forum full of geniuses :-)

    Who here knows the most about the include function?

  • #11
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am still having this problem.
    Am I the only one?

    Can someone/anyone please let me know what happens when they visit?

    Thank You,
    Dan

  • #12
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if statements ...

    Although "if" statements can run in certain circumstances without {}
    the practice is really bad form. Your code is full of instances of questionable conditionals. The fact that fixing a single instance of a missing {} isn't any surprise, you are missing a huge number of them.

    Perhaps this will help:


    http://www.tizag.com/phpT/if.php

    HTH, vbplusme

  • #13
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Alright, well looking at the error it produces "

    Warning: include() [function.include]: URL file-access is disabled in the server configuration in /mounted-storage/home98c/sub005/sc12597-JIYA/pixelsfortroops/index.php on line 98"

    You've got file access problems. A quick google of the error got me this link here which should be able to help you. Also This site looks like it should be helpful to you as well.

    Also you can try making your include
    PHP Code:
    include 'menu.html'
    or
    PHP Code:
    include (menu.html); 
    and see if either of those work. Hope I was able to be of some help.

  • #14
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    gents,

    thank you for your help.

    kochier - i'm sorry, you caught me during messing with some other options. You won't get any errors if you go back now.

    vbplusme - I will check out your suggested link, that you for your help.



    Does anyone else get the 'pop-up' when they visit index.php?
    I have the cookie set to expire immediately. Also, please scroll down to see if the menu floats down and follows, it should.

    Thanks again..
    dan

  • #15
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Yes I get the pop-up when I go to both your pages, and the menu scrolls on both as well. Curious, what did you do to fix it?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •