#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Question Need urgent help


    I do have a PHP script with run fine on my local sever. When i do upload to the production sever it dose not function correctly.
    My local sever uses Apache/2.2.22 (Win32) PHP/5.4.5.
    Here is an example of the code.
    PHP Code:
    <?php
        
    require_once('lib/bookmark_fns.php');
        
    // The shopping cart needs sessions, so start one
        
    session_start();
        
        
    $itemId $_GET['itemid'];
        
    // get this book out of database
        
    $items get_item_details($itemId);
        foreach(
    $items as $item)
            
    do_html_header($item['ITEM_NAME']);
            
    check_valid_user();
            
    display_item_details($items);
        
            
    // set url for "continue button"
            
    $target "index.php";
            if(
    $itemId
            {
                
    $target "show_cat.php?catid=".$item['CATEGORY_ID'];
            }
        
            
    // if logged in as admin, show edit book links
            
    if(check_admin_user())
            {
                
    display_button("edit_item_form.php?itemid=".$itemId"edit-item""Edit Item");
                
    display_button("admin.php""admin-menu""Admin Menu");
                
    //display_button($target, "continue", "Continue");
            

            else 
            {
                
    display_button("show_cart.php?new=".$itemId"add-to-cart""Add ".$item['ITEM_NAME']." To My Shopping Cart");
                
    display_button($target"continue-shopping""Continue Shopping");
            }
            
    do_html_footer();
    ?>
    Here is the problem, on my local sever I must include the foreach loop to access the array from the Sql query. On the production sever it tells me i do have an wrong foreach construct. Help please.
  2. #2
  3. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Sep 2003
    Location
    Germany
    Posts
    1,355
    Rep Power
    323
    Missing braces in your foreach() ?
    IkoTikashi - ikotikashi.de
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Need urgent help


    Originally Posted by IkoTikashi
    Missing braces in your foreach() ?
    That is where i do have a problem. Why dose it function on my local sever? I am suppose to access my array with say
    PHP Code:
    $items['ITEM_NAME'
    , without the foreach loop.
    Thanks
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    What does get_item_details return?

    Missing braces in your foreach() ?
    The foreach construct here *might* be working depending on what get_item_details returns (but it's still an ugly way to program it regardless).

    I'm assuming that get_item_details is only supposed to return database data for one item. But if it returns an array of database rows that looks something like this:
    Code:
    array(
      array(
        'key' => 'value',
      )
    )
    Then the foreach statement is essentially being used to do this:
    PHP Code:
    $items get_item_details($itemId); 
    $item $items[0]; 
    And thus would actually work correctly.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Thumbs up Need urgent help


    Thanks .
    The get_item_details was suppose to return an SQL query in an array. I had already looped throw the array in some other function.
    So i had to foreach loops looping over the same array.
    Thanks a lot you where of great help.

IMN logo majestic logo threadwatch logo seochat tools logo