Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My little script
Index -> Programming, PHP -> PHP Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JSBN




PostPosted: Fri Mar 26, 2004 11:35 pm   Post subject: My little script

ok, the first part of my script works well (but that's probly because i stole alot of it out of my resources) but now, i'm making my own script from scratch, w/o the resources i had b4(to explain a bit more, i'm making a script for my site that reads out of a file, which is made in the admin area of my phpbb forum [that part works well])

So, i'm getting the error:
Quote:
Fatal error: Call to a member function on a non-object in /homepages/43/d87567952/htdocs/Postrec.php on line 4


Here's my code
code:
<?php
include ('Poster.php');

$template->set_filenames(array(
        'body' => '/News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');
?>


As i'm sure you will notice, there are many similarities to my code and that of some phpbb scripts, and that could be part of my problem.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Mar 26, 2004 11:55 pm   Post subject: (No subject)

From the rror message, I'd say look at the point in the code where $template is initialazed. It's not becoming an object.
JSBN




PostPosted: Sat Mar 27, 2004 8:44 am   Post subject: (No subject)

yea..... how would i do that? as i am unsure of how i should initalize the $template variable
wtd




PostPosted: Sat Mar 27, 2004 10:05 am   Post subject: (No subject)

Well, what class is $template supposed to be an object of?
JSBN




PostPosted: Sat Mar 27, 2004 11:28 am   Post subject: (No subject)

ok, because i am an uber newb at PHP, i will put it simply as: i am trying to use $template as it is used throughout phpBB
Amailer




PostPosted: Sat Mar 27, 2004 3:16 pm   Post subject: (No subject)

JSBN wrote:
ok, because i am an uber newb at PHP, i will put it simply as: i am trying to use $template as it is used throughout phpBB
'
hmm
your missing the important file for your script to work.
code:

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
include ('Poster.php');

$template->set_filenames(array(
        'body' => '/News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');
?>
JSBN




PostPosted: Sat Mar 27, 2004 3:51 pm   Post subject: (No subject)

yea.. i should probly have updated my code for you guys to help me with. what i have now is:
code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '/Forum';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, 0);
init_userprefs($userdata);
include ('Poster.php');

$template->set_filenames(array(
        'body' => '/News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');


but now i get:
Quote:
Fatal error: Call to undefined function: session_pagestart() in C:\Documents and Settings\James\My Documents\Backup1\Web Site\Postrec.php on line 7
Amailer




PostPosted: Sat Mar 27, 2004 4:24 pm   Post subject: (No subject)

JSBN wrote:
yea.. i should probly have updated my code for you guys to help me with. what i have now is:
code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '/Forum';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, 0);
init_userprefs($userdata);
include ('Poster.php');

$template->set_filenames(array(
        'body' => '/News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');


but now i get:
Quote:
Fatal error: Call to undefined function: session_pagestart() in C:\Documents and Settings\James\My Documents\Backup1\Web Site\Postrec.php on line 7


go to
Postrec.php

remove
code:

$userdata = session_pagestart($user_ip, 0);
init_userprefs($userdata);
JSBN




PostPosted: Sat Mar 27, 2004 5:42 pm   Post subject: (No subject)

Removed it, but now i get:
Quote:
Fatal error: Call to a member function on a non-object in /homepages/43/d87567952/htdocs/Postrec.php on line 9
Amailer




PostPosted: Sat Mar 27, 2004 6:33 pm   Post subject: (No subject)

JSBN wrote:
Removed it, but now i get:
Quote:
Fatal error: Call to a member function on a non-object in /homepages/43/d87567952/htdocs/Postrec.php on line 9


show us the code in Postrec.php
JSBN




PostPosted: Sat Mar 27, 2004 6:36 pm   Post subject: (No subject)

code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '/Forum';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include ('Poster.php');

$template->set_filenames(array(
        'body' => '/News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');

?>
Amailer




PostPosted: Sat Mar 27, 2004 6:40 pm   Post subject: (No subject)

god, i got confused (looks same) i ment Poster.php, sry

also
code:

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './Forum';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include ('Poster.php');

$template->set_filenames(array(
        'body' => 'News.tpl')
);
$template->assign_vars(array(
           'L_POST1'=> $poster['Post1'],
           'L_POST2'=> $poster['Post2'],
           'L_POST3'=> $poster['Post3'],
           'L_POST4'=> $poster['Post4'],
           'L_POST5'=> $poster['Post5'],
           'L_POST6'=> $poster['Post6'],
           'L_POST7'=> $poster['Post7'],
           'L_POST8'=> $poster['Post8'],
           'L_POST9'=> $poster['Post9'],
           'L_POST10'=> $poster['Post10'])
);

$template->pparse('body');

?>

you don't need / before news.tpl
JSBN




PostPosted: Sat Mar 27, 2004 6:53 pm   Post subject: (No subject)

Poster.php
code:
<?php
$poster['Post1']= 'This is post #1';
$poster['Post2']= 'This is post #2';
$poster['Post3']= 'This is post #3';
$poster['Post4']= 'This is post #4';
$poster['Post5']= 'This is post #5';
$poster['Post6']= 'This is post #6';
$poster['Post7']= 'This is post #7';
$poster['Post8']= 'This is post #8';
$poster['Post9']= 'This is post #9';
$poster['Post10']= 'This is post #10';
?>
wtd




PostPosted: Sat Mar 27, 2004 7:37 pm   Post subject: (No subject)

Amailer wrote:
you don't need / before news.tpl


He certainly does. "./News.tpl" is the same as "News.tpl", but "/News.tpl" indicates that News.tpl must be at the server's root directory.
Amailer




PostPosted: Sat Mar 27, 2004 7:44 pm   Post subject: (No subject)

wtd wrote:
Amailer wrote:
you don't need / before news.tpl


He certainly does. "./News.tpl" is the same as "News.tpl", but "/News.tpl" indicates that News.tpl must be at the server's root directory.


if you look at the phpBB template classes, it's no need they do everything already.

And, i don't know what's wrong... either something wrong with your common.php or.. or idk .. put that file in the same place as the common.php
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 27 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: