PDA

View Full Version : Where in the PHP file can I put my database code?


afullcup
07-22-2006, 08:13 PM
Feeling pretty silly here - I feel like I am a pretty decent coder and database developer, but I am new to the vbulletin world and the marriage of php and mysql and can't seem to get it going!

I seem to be unable to execute PHP code if that makes any sense. I have tried putting something as simple as this in my template:

<?php
print("in php");
?>

but it doesn't print. I tried putting the same code into a .php file on the server and used $filename.php to include it in the template and it doesn't print.

I searched all other templates on my site for "<?php" and there doesn't appear to be anywhere that uses it, so I don't have anything to copy.

I am wondering if there is some sort of configuration file that allows/disallows the use of PHP in a template?? If so, is there a reason that it isn't used more? How on earth do I get my php to run?! Pulling my hair out here! :)

Any help is much appreciated!!

Guest190829
07-22-2006, 09:17 PM
vBulletin prevents php from being executed directly in the templates for a number of reason. One of the main reason for this is to allow a seperation of html and php code.

This tutorial should help you:

https://vborg.vbsupport.ru/showthread.php?t=98009

:)

afullcup
07-22-2006, 09:32 PM
Thanks a million!! :)

OK - So I got a new page going using the examples in that tutorial. But I'm kind of back to the same issue of not knowing where to put my code so that it displays on my page!

I basically want to grab data out of a table and display it on my page. These are the last 3 lines of my php file:
print("testing6\n");
eval('print_output("' . fetch_template('test_page') . '");');
print("testing7\n");

testing6 is printed at the very top of my page and testing7 isn't printed at all (which I'm sure is no surprise to you). I just don't understand where it is I'm supposed to put the database coding in order to have it displayed on my page below my header given that it is PHP code and isn't allowed in the template.

I hope that makes sense and I hope someone is around and willing to answer a silly question again. :)

anyone around to help me out? pretty please! :)

afullcup
07-26-2006, 01:11 AM
anyone??

markp_2000
07-26-2006, 02:57 AM
I had the same issues. I jotted down how I got it to work in this post. You are going through the same stuff I did, so I think it will work for you as well

https://vborg.vbsupport.ru/showthread.php?t=121361

I also wrote some database code to see how it works as well. Very similar to the above. I can post it as well if needed.

Mark

afullcup
07-26-2006, 03:25 PM
Thank you Mark! I would love to see the database code as well.