Custom PHP...

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Ideas Centre
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
kevincon
Registered User
Posts: 27
Joined: Sat Jul 26, 2008 10:28 pm

Custom PHP...

Post by kevincon » Sun Feb 15, 2009 9:33 pm

I have a custom index setup for my forum. Looks like this...

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('Home');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
    ?>
I changed it to this...

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('Home');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
    ?>
	
	<?php
	

						$query = "SELECT * FROM home_body WHERE username='kevin'";
						
						$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

						
						if (mysql_num_rows($result) > 0) {
    	
						while($row = mysql_fetch_array($result)) {
						echo $row["content"];
						    					}
						} else {

    					echo "No rows found!";
						}
						
	?>

The PHP i put in doesn't wanna show up, How else could i pull up information from a table on my index?
How could i get my own custom PHP to show up on my index page?
I also tried to put PHP on the template file in the STYLE but that proved no good...

User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: Custom PHP...

Post by John P » Sun Feb 15, 2009 9:36 pm

You should use the dbal for your queries and assign the output to $template.
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

kevincon
Registered User
Posts: 27
Joined: Sat Jul 26, 2008 10:28 pm

Re: Custom PHP...

Post by kevincon » Sun Feb 15, 2009 9:42 pm

I need you to be more specific...

Mr. Bond
Registered User
Posts: 54
Joined: Mon Feb 04, 2008 1:11 pm

Re: Custom PHP...

Post by Mr. Bond » Sun Feb 15, 2009 9:53 pm

kevincon wrote:I need you to be more specific...
The DBAL is the Database Abstraction Layer that phpBB3 uses, and Stef775 is saying you should use the template engine to output the data. These links may help :)

kevincon
Registered User
Posts: 27
Joined: Sat Jul 26, 2008 10:28 pm

Re: Custom PHP...

Post by kevincon » Sun Feb 15, 2009 9:55 pm

I will look into this, Thank you very much. :D

kevincon
Registered User
Posts: 27
Joined: Sat Jul 26, 2008 10:28 pm

Re: Custom PHP...

Post by kevincon » Sun Feb 15, 2009 10:03 pm

I'm looking at this wiki, and wondering what the hell am i looking at. I'm still having trouble, How could i use the script i made, basically pull up the info from my table...Any one want to help me figure this out?

kevincon
Registered User
Posts: 27
Joined: Sat Jul 26, 2008 10:28 pm

Re: Custom PHP...

Post by kevincon » Sun Feb 15, 2009 11:36 pm

Basically my question is, how could i pull up the information on a table in the phpbb database. And the perhaps show it on the template? I'm very lost.

Locked

Return to “[3.0.x] Support Forum”