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.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2011
    Posts
    117
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Help me on smarty setup error

    Hi ,
    I am setting up a smarty template but it giving me an errors

    Here is the error but mean while i have write the dir correct

    Here is the error

    ( ! ) Warning: require(smarty_connect.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\index.php on line 3
    Call Stack
    # Time Memory Function Location
    1 0.0025 364824 {main}( ) ..\index.php:0

    ( ! ) Fatal error: require() [function.require]: Failed opening required 'smarty_connect.php' (include_path='.;C:\php\pear') in C:\wamp\www\index.php on line 3
    Call Stack
    # Time Memory Function Location
    1 0.0025 364824 {main}( )


    And the pages are : index.php which is inside my main www dir

    PHP Code:
    <?php
      
    //starting index.php
       
    require('smarty_connect.php');
       
    $smarty= new smarty_connect.php;
       
    $smarty->assign('name','Clement');
       
    $smarty->display('index.tpl');
    ?>
    And smarty_connect.php page which is outside the www root dir ..so i created a folder called smarty in disc c; and inside the smarty folder is where my demo, libs, template_c, cache folders are
    here the code for smarty_connect.php
    PHP Code:
     //smarting smarty connect
      
      //first loading smarty libraries
      
    require('smarty.class.php');
     class 
    smarty_connect extends smarty{
       
        function 
    smarty_connect(){
        
    $smarty= new smarty;
        
        
    $this->smarty();

           
    $this->template_dir='C:\wamp\www\Smarty\templates';
           
    $this->config_dir='C:\wamp\www\Smarty\config';
           
    $this->compile_dir='C:\Smarty\templates_c';
           
    $this->cache_dir='C:\Smarty\cache';


        }
     }

    ?> 
    And finally index.tpl page which is inside 'C:\Smarty\templates_c' means inside template_c
    here is the code

    <html>
    <body>

    Hello,{$name}
    </body>
    </html>


    Please help,
    Thanks

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by kingot View Post
    Hi ,
    I am setting up a smarty template but it giving me an errors

    Here is the error but mean while i have write the dir correct

    Here is the error

    ( ! ) Warning: require(smarty_connect.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\index.php on line 3
    Call Stack
    # Time Memory Function Location
    1 0.0025 364824 {main}( ) ..\index.php:0

    ( ! ) Fatal error: require() [function.require]: Failed opening required 'smarty_connect.php' (include_path='.;C:\php\pear') in C:\wamp\www\index.php on line 3
    Call Stack
    # Time Memory Function Location
    1 0.0025 364824 {main}( )


    And the pages are : index.php which is inside my main www dir

    PHP Code:
    <?php
      
    //starting index.php
       
    require('smarty_connect.php');
       
    $smarty= new smarty_connect.php;
       
    $smarty->assign('name','Clement');
       
    $smarty->display('index.tpl');
    ?>
    And smarty_connect.php page which is outside the www root dir ..so i created a folder called smarty in disc c; and inside the smarty folder is where my demo, libs, template_c, cache folders are
    here the code for smarty_connect.php
    PHP Code:
     //smarting smarty connect
      
      //first loading smarty libraries
      
    require('smarty.class.php');
     class 
    smarty_connect extends smarty{
       
        function 
    smarty_connect(){
        
    $smarty= new smarty;
        
        
    $this->smarty();

           
    $this->template_dir='C:\wamp\www\Smarty\templates';
           
    $this->config_dir='C:\wamp\www\Smarty\config';
           
    $this->compile_dir='C:\Smarty\templates_c';
           
    $this->cache_dir='C:\Smarty\cache';


        }
     }

    ?> 
    And finally index.tpl page which is inside 'C:\Smarty\templates_c' means inside template_c
    here is the code

    <html>
    <body>

    Hello,{$name}
    </body>
    </html>


    Please help,
    Thanks
    The error message means it can't find the file in the path you've given. You've only given a filename, so it looks in the same directory as the executing script - in your case, index.php. It's not there, because it's above root dir. So, you need to either give it an absolute path
    PHP Code:
    require('C:/path/to/smarty_connect.php'); 
    or a relative path
    PHP Code:
    require('../path/to/smarty_connect.php'); 
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    Regular Coder
    Join Date
    Feb 2011
    Posts
    117
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hi Sir,

    Thanks very much for your support but unfortunatly, it still not working..!!
    I''m trying many ways but still not getting it..!!
    Now giving me this error

    ( ! ) Fatal error: Uncaught exception 'SmartyException' with message 'PHP5 requires you to call __construct() instead of Smarty()' in C:\Smarty\libs\sysplugins\smarty_internal_templatebase.php on line 803
    ( ! ) SmartyException: PHP5 requires you to call __construct() instead of Smarty() in C:\Smarty\libs\sysplugins\smarty_internal_templatebase.php on line 803


    Thanks


  •  

    Posting Permissions

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