Hi, hope someone can help. I have been creating a site (for myself) using paypal shopping vart, but i have since discovered that its not fit for purpose & therefore after much searching i have decided to use "OpenCart", but instead of using the default OpenCart shop front I want to use my exisitng site desing and was hoping that I could intergrate certain php code from OpenCart into my site. I therefore installed opencart in the root of my site & then renamed the opencart index.php & copied my site across & started coping the contents of the opencart index.php into my website index.php and was able to copy everything across apart from...

// Session -
require(DIR_INCLUDE . 'session.php');
$session = new session;

as the session section produces the error...

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/zoapho90/public_html/index.php:9) in /home/zoapho90/public_html/include/session.php on line 22

and the below displays the default template that i dont want.

// Display Template
echo($template->fetch('layout.tpl'));

Therefore why am i getting the above error & would my theory work by coping the opencart index.php php code into my php page & then enter php code to display products, etc?

I hope that makes sense.

    Are you using any includes? If not try creating the session as the first line after your opening php tag:

    <?
         session_start();
    ?>
    

    See if that helps. If you are using includes make sure that the scripts or pages you include do not start a session that you're unaware of. If they do, that would cause your problem. It almost seems like you're requiring session.php which starts the session, and the on the next line start a new session?

      hi, that worked. Easy when you know how. Following on with the question...

      Now i have the original php code from the opencart index.php embeded in my own index.php, is it possible to call php commands from the application/database such a product details, catogory names, etc and display them on my site? I went to the template file and copied <?php echo $category; ?> and placed in my site, but get the message

      Notice: Undefined variable: category in /home/zoapho90/public_html/index.php on line 181

      on my site.

        You could include the index.php from the opencart script as follows:

        include ("/path/to/open/cart/index.php");
        

        And to call the variables you just have to know what they are called inside the open cart index file. Hope this helps.

          Hi, I copied that line of code into the php section of my index.php, but get the following errors when i load the page.

          Warning: main(): open_basedir restriction in effect. File(/opencart/index.php) is not within the allowed path(s): (/home/zoapho90/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/zoapho90/public_html/index.php on line 102
          
          Warning: main(/opencart/index.php): failed to open stream: Operation not permitted in /home/zoapho90/public_html/index.php on line 102
          
          Warning: main(): open_basedir restriction in effect. File(/opencart/index.php) is not within the allowed path(s): (/home/zoapho90/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/zoapho90/public_html/index.php on line 102
          
          Warning: main(/opencart/index.php): failed to open stream: Operation not permitted in /home/zoapho90/public_html/index.php on line 102
          
          Warning: main(): Failed opening '/opencart/index.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zoapho90/public_html/index.php on line 102
          

          I therefore checked line 102 & it is the line of code i copied in. Any idea's?

          Thanks in advance,

            Seems like the index.php file for open-cart has to be in a predefined path. Don't copy the index.php file into the same directory as your script in question. Instead put it in the directory it's required to be in and put the full path in the include().

              Hi, I copied

              include ("/opencart/index.php");

              into my index.php on my root after cheking the opencart index.php locatation and its stored on root\opencart

              but if the slash before opencart is "\"

              i get

              Warning: main(\opencart/index.php): failed to open stream: No such file or directory in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(\opencart/index.php): failed to open stream: No such file or directory in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(): Failed opening '\opencart/index.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zoapho90/public_html/index.php on line 102
              

              and if i put "/" i get

              Warning: main(): open_basedir restriction in effect. File(/opencart/index.php) is not within the allowed path(s): (/home/zoapho90/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(/opencart/index.php): failed to open stream: Operation not permitted in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(): open_basedir restriction in effect. File(/opencart/index.php) is not within the allowed path(s): (/home/zoapho90/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(/opencart/index.php): failed to open stream: Operation not permitted in /home/zoapho90/public_html/index.php on line 102
              
              Warning: main(): Failed opening '/opencart/index.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zoapho90/public_html/index.php on line 102
              

              sorry about this, but i am a bit of a noob

                I'd advise to check the manual for OpenCart then. It's obvious that the program is looking for files in specific places.

                  ok thanks, but just one last q, if I enter the command

                  // Display Template
                  echo($template->fetch('layout.tpl'));

                  into my index (this is the only command not copied across from the opencart index.php) it displays the working shop front. Therefore i checked the layout.tpl file (/public_html/opencart/catalog/template/default) to see if i could figure it out. The tpl file looks like this...

                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

                  <html dir="<?php echo $dir; ?>" lang="<?php echo $lang; ?>">

                  <head>

                  <title><?php echo $title; ?></title>

                  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>">

                  <base href="<?php echo $href; ?>">

                  <link rel="stylesheet" type="text/css" href="catalog/template/default/stylesheet.css">

                  <script type="text/javascript" src="catalog/javascript/popup.js"></script>

                  </head>

                  <body>

                  <h1><?php echo $title; ?></h1>

                  <div id="container">

                  <div id="header"><?php echo $header; ?></div>

                  <div id="bar"><?php echo $language; ?><?php echo $currency; ?><?php echo $search; ?></div>

                  <div id="column"><?php echo $cart; ?><?php echo $category; ?><?php echo $review; ?><?php echo $information; ?></div>

                  <div id="content"><?php echo @$content; ?></div>

                  <div id="footer"><?php echo $footer; ?></div>

                  </div>

                  <?php if (@$time) { ?>

                  <div id="time"><?php echo $time; ?></div>

                  <?php } ?>

                  </body>

                  </html>

                  any ideas, before i give up :o)

                    All that's doing is calling variables to and echoing simple things from the rest of the programs scripts. You need to find out what the open_basedir refers to. Looks like it's an action taken by the function main(). Find where main() is defined and see if you can discern from the statements inside the function body what is supposed to happen.

                      Write a Reply...