SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem in smarty .....

    Hello forum
    i am getting problem in smarty
    case:
    wwwroot/mySite/admin has files like
    -index.php
    -listA.php
    -listB.php
    /templates/ folder has
    -header.tpl
    -footer.tpl
    -index.tpl
    -listA.tpl
    -listB.tpl
    index.php contains
    PHP Code:
    <?php
    //in upper section it includes all the class files and creates the respective objects
    // neccessary processing goes here...
    $smarty->display("index.tpl");
    ?>
    index.tpl contains
    PHP Code:
    {php}
    if(isset(
    $_GET['action']))
    {
        
    $filename $_GET['action'].".php";
        if(
    file_exists($filename))
        {
            include 
    "$filename";
        }
        else
        {
    //error
            
    }
    {/
    php
    :::means it automatically includes the file as per $_GET action
    suppose i clicked on the link ?action=listA then it auto includes the page listA.php which then display the array data in listA.tpl

    problem:
    It was working in normal case ie without using smarty but Now whenever i clik on the links
    it shows:
    Call to a member function selectAll() on a non-object in C:\Program Files\xampp\htdocs\mySite\admin\listA.php on line 39
    i am not getting the solution please help.
    Thanks in advance to all of you!!

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    I dont use smarty but what is on line 39? and have you included all the correct files for the classes?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe re-organizing your code a little would help:

    index.php:
    PHP Code:
    <?php
    if(isset($_GET['action']))
    {
        
    $filename $_GET['action'].".php";
        if(
    file_exists($filename))
        {
            include 
    "$filename";
        }
        else
        {
    //error
            
    }

    //in upper section it includes all the class files and creates the respective objects
    // neccessary processing goes here...
    $smarty->display("index.tpl");
    ?>
    You want to have as little php in the template itself as possible. That way designers and non-programmers can mess with the page without braking your underlying php functionality (if you have a distributed work environment). But it's also good MVC practice.

    I doubt that will get rid of the error, but could you list the code for file listA.php? You'll want to look at line 39 there, that's where your problem is. It sounds like your trying to do something like $recordset->selectAll(), or some sort of database manipulation on a database object that hasn't been instantiated yet.


Bookmarks

Posting Permissions

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