Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2004, 12:06 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Coding Help

Ok, I'm attempting to pll info from a database (the same database my vB uses) and still be able to use vB's template system on the page. I've been able to get the template to work, just not the info from the database. I'm not sure exactly what I'm doing wrong. The system I have going on my site right now works, but when I try to combine it with vB I mess it up some how. Can someone look at my code and tell me where I'm going wrong?

Also I'm attempting to have my episodes be called like this: file.php?action=episodeguide&episode=101 (101 is the number in the id row)

Template Code:
Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

<table border="0" cellspacing="0" 

 

width="100%" cellpadding="0">
              <tr>
                <td width="100%">
                <table border="0" cellspacing="0" 

 

width="100%" 

cellpadding="0">
                  <tr>
                    
          <td width="24" id="top"> <img border="0" src="images/smallville/left_top.jpg" width="24" height="6" /></td>
                    
          <td width="100%" 

background="images/smallville/top.jpg"> <img border="0" src="images/smallville/top.jpg" width="2" height="6" /></td>
                    
          <td width="19" align="right"> <img border="0" src="images/smallville/right_top.jpg" width="19" height="6" /></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_corner.jpg" width="24" height="19" /></p></td>
                    <td width="100%" 

background="images/smallville/top_mid.jpg">
                     <b><font face="Verdana" size="1" color="#CC9966">Smallville 
                     Episode Guide</font></b></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_corner.jpg" width="19" height="19" /></p></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_second.jpg" width="24" height="16" /></p></td>
                    <td id="top" width="100%" 

background="images/smallville/second_mid.jpg">
                    <p align="left"> <b><font face="Verdana" size="1" color="#CC9966">
		$id - $episode_name</font></b></p></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_second.jpg" width="19" height="16" /></p></td>
                  </tr>
                  <tr>
                    <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg">
                    <p align="left"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></p></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0" 

 

width="100%" 

 cellpadding="4">
                      <tr>
                        <td width="100%" valign="top">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            <td width="100%">
                            <p align="left"> <font face="Verdana" size="1" color="#CC9966">
        $episode_description
	</font></p></td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg">
                    <p align="right"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></p></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/left_maroon_bottom.jpg" width="24" height="13" /></td>
                    <td width="100%" id="top" 

background="images/smallville/maroon_mid.jpg" valign="bottom">
                    
                    <p align="center"><font size="1" face="Verdana">&nbsp;</font></p></td>
                    <td width="19" valign="baseline">
                    <p align="right"> <img border="0" src="images/smallville/right_maroon_bottom.jpg" width="19" height="13" /></p></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_bottom.jpg" width="24" height="18" /></p></td>
                    <td width="100%" 

background="images/smallville/bottom.jpg">
                    <p align="left"> <img border="0" src="images/smallville/bottom.jpg" width="3" height="18" /></p></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_bottom.jpg" width="19" height="18" /></p></td>
                  </tr>
                  <tr>
                    
          <td width="24" id="top"> <img border="0" src="images/smallville/left_top.jpg" width="24" height="6" /></td>
                    
          <td width="100%" 

background="images/smallville/top.jpg"> <img border="0" src="images/smallville/top.jpg" width="2" height="6" /></td>
                    
          <td width="19" align="right"> <img border="0" src="images/smallville/right_top.jpg" width="19" height="6" /></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_corner.jpg" width="24" height="19" /></p></td>
                    <td width="100%" 

background="images/smallville/top_mid.jpg">
                     <b><font face="Verdana" size="1" color="#CC9966">Extras</font></b></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_corner.jpg" width="19" height="19" /></p></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_second.jpg" width="24" height="16" /></p></td>
                    <td id="top" width="100%" 

background="images/smallville/second_mid.jpg">
                    <p align="left"> <b><font face="Verdana" size="1" color="#CC9966">Original 
              Air Date</font></b></p></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_second.jpg" width="19" height="16" /></p></td>
                  </tr>
                  <tr>
                    <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg">
                    <p align="left"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></p></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0" 

 

width="100%" 

 cellpadding="4">
                      <tr>
                        <td width="100%" valign="top">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            <td width="100%">
                            <font face="Verdana" size="1" color="#CC9966">
							$air_date</font></td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg">
                    <p align="right"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></p></td>
                  </tr>
                  <tr>
                                        
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/con_left.jpg" width="24" height="17" /></td>
                    <td width="100%" background="images/smallville/con_middle.jpg">
                    <b><font face="Verdana" size="1" color="#CC9966">Music</font></b></td>
                    
          <td width="19" valign="baseline"> <img border="0" src="images/smallville/con_right.jpg" width="19" height="17" /></td>
</tr>
                  <tr>
                    <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg">
                    <p align="left"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></p></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0" 

 

width="100%" 

 cellpadding="4">
                      <tr>
                        <td width="100%" valign="top">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            
                      <td width="100%"> <font face="Verdana" size="1" color="#CC9966">
					  $music</td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg">
                    <p align="right"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></p></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/con_left.jpg" width="24" height="17" /></td>
                    <td width="100%" background="images/smallville/con_middle.jpg">
                    <b><font face="Verdana" size="1" color="#CC9966">Guest Stars</font></b></td>
                    
          <td width="19" valign="baseline"> <img border="0" src="images/smallville/con_right.jpg" width="19" height="17" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0"  width="100%" cellpadding="4">
                      <tr>
                        <td width="100%">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            
                      <td width="100%"> <font face="Verdana" size="1" color="#CC9966">
					  $guest_stars</font></td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    
          <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/con_left.jpg" width="24" height="17" /></td>
                    <td width="100%" background="images/smallville/con_middle.jpg">
                    <b><font color="#CC9966" size="1" face="Verdana">Written By</font></b></td>
                    
          <td width="19" valign="baseline"> <img border="0" src="images/smallville/con_right.jpg" width="19" height="17" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0"  width="100%" cellpadding="4">
                      <tr>
                        <td width="100%">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            <td width="100%">
                            <font face="Verdana" size="1" color="#CC9966">
					  $written_by
					 </font></td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    
          <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/con_left.jpg" width="24" height="17" /></td>
                    <td width="100%" background="images/smallville/con_middle.jpg">
                    <b><font face="Verdana" size="1" color="#CC9966">Directed By</font></b></td>
                    
          <td width="19" valign="baseline"> <img border="0" src="images/smallville/con_right.jpg" width="19" height="17" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline" 

background="images/smallville/left_mid.jpg"> <img border="0" src="images/smallville/left_mid.jpg" width="24" height="5" /></td>
                    <td width="100%" bgcolor="#000000">
                    <table border="0" cellspacing="0"  width="100%" cellpadding="4">
                      <tr>
                        <td width="100%">
                        <table border="0" cellspacing="0"  width="100%" cellpadding="3">
                          <tr>
                            <td width="100%">
                            <font face="Verdana" size="1" color="#CC9966">
					  $directed_by
					  </font></td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table>
                    </td>
                    
          <td width="19" valign="baseline" 

background="images/smallville/right_mid.jpg"> <img border="0" src="images/smallville/right_mid.jpg" width="19" height="5" /></td>
                  </tr>
                  <tr>
                    
          <td width="24" valign="baseline"> <img border="0" src="images/smallville/left_maroon_bottom.jpg" width="24" height="13" /></td>
                    <td width="100%" id="top" 

background="images/smallville/maroon_mid.jpg" valign="bottom">
                    
                    <p align="center"><font size="1" face="Verdana">&nbsp;</font></p></td>
                    <td width="19" valign="baseline">
                    <p align="right"> <img border="0" src="images/smallville/right_maroon_bottom.jpg" width="19" height="13" /></p></td>
                  </tr>
                  <tr>
                    <td width="24">
                    <p align="left"> <img border="0" src="images/smallville/left_bottom.jpg" width="24" height="18" /></p></td>
                    <td width="100%" 

background="images/smallville/bottom.jpg">
                    <p align="left"> <img border="0" src="images/smallville/bottom.jpg" width="3" height="18" /></p></td>
                    <td width="19" align="right">
                    <p> <img border="0" src="images/smallville/right_bottom.jpg" width="19" height="18" /></p></td>
                  </tr>

                  </table>
                </td>
              </tr>
</table>



$footer
</body>
</html>
Page Code:
PHP Code:
<?php 
// ####################### SET PHP ENVIRONMENT ########################### 

error_reportingE_ALL & ~E_NOTICE ); 

// #################### DEFINE IMPORTANT CONSTANTS ####################### 

define'NO_REGISTER_GLOBALS'); 

define'THIS_SCRIPT''test' ); 

// ################### PRE-CACHE TEMPLATES AND DATA ###################### 

// get special phrase groups 

$phrasegroups = array(); 

// get special data templates from the datastore 

$specialtemplates = array(); 

// pre-cache templates used by all actions 

$globaltemplates = array( 'episode_guide' ); 

// pre-cache templates used by specific actions 

$actiontemplates = array(); 

// ######################### REQUIRE BACK-END ############################ 

require_once( './global.php' ); 

// ######################## START MAIN SCRIPT ############################ 
$db mysql_connect('localhost''---''----') or die('Couldn\'t connect to the database.');    
mysql_select_db('---'$db) or die('Couldn\'t select the database');

switch (
$_GET['action']) { 
case 
'episodeguide':
$query 'select * from smallville_episode_guide where id="' $_GET'episode' ] . '"'
$result "mysql_query($query$db) or die($query.' failed: '.mysql_error())";   
$row "mysql_fetch_assoc($result)"
$id "$row[id]"
$episode_name "$row[episode_name]"
$episode_description "$row[episode_description]"
$air_date "$row[air_date]"
$music "$row[music]"
$guest_stars "$row[guest_stars]"
$written_by "$row[written_by]"
$directed_by "$row[directed_by]"
eval( 
'print_output( "' fetch_template'episode_guide' ) . '" );' );
}
?>
I'd also like to mention that I do seem to be getting some kind of info on the page. Everwhere a variable is I get an m.

http://www.thekryptonian.com/test.ph...de&episode=102 (its going to look wierd so you may want to use the style select to choose the smallville theme)
Reply With Quote
  #2  
Old 08-02-2004, 12:24 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well for sure you can, instead of connecting to the database again, use the connection made by vB

you can use

Code:
switch ($_GET['action']) { 
case 'episodeguide': 
$episode = intval($_POST['episode']);
$row = $DB_site->query_first("SELECT * FROM smallville_episode_guide WHERE id=$episode");

$id = "$row[id]"; 
$episode_name = "$row[episode_name]"; 
$episode_description = "$row[episode_description]"; 
$air_date = "$row[air_date]"; 
$music = "$row[music]"; 
$guest_stars = "$row[guest_stars]"; 
$written_by = "$row[written_by]"; 
$directed_by = "$row[directed_by]"; 
eval( 'print_output( "' . fetch_template( 'episode_guide' ) . '" );' );
also, I would just use $row[episode_name] in the template, instead of $episode name. If you change all those things, you can delete most of the bottom part...
Reply With Quote
  #3  
Old 08-02-2004, 06:20 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey thanks! that worked except I had to make one change, $_GET to $_POST
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:50 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04051 seconds
  • Memory Usage 2,239KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete