The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Custom Page will not render after adding database connection
I have some custom pages that I have moved the variables from the .php file into a database.
I've tested the database connection on its own and everything works fine. But as soon as I add the database code to the vB custom page the page no longer renders (just shows a blank page). Here is a sample of the database code I've tried to insert into the custom page: Code:
// Get parameters from url query string $db = new dbPDO(); $cruiseport_id = !empty($_GET['id'])?intval($_GET['id']):1; // get all the values form your table limited to the first matching row (thre should only be one $query = "SELECT * FROM cruiseports WHERE cruiseport_id = :cruiseportid limit 1"; // the prepare and bind methods prevent any sort of SQL injection (ie bad stuff in the $id value) $stmt = $db->prepare($query); $stmt->bindValue(":cruiseportid",$cruiseport_id); $stmt->execute(); // we are only expecting 1 row here... $port = $stmt->fetch(PDO::FETCH_ASSOC); |
#2
|
||||
|
||||
Are you sure you are even connecting to the database? Is there anything in your error_logs (if you don't know where they are, ask your host)?
Lynne Sands vBulletin Support Staff vBulletin.org Admin |
#3
|
||||
|
||||
Well after hours of trying to track it down it came out to be a simple solution.
Had to replace: Code:
print_output($templater->render()); With: Code:
echo($templater->render()); before the php close. Can anyone shed light on why print_output wouldn't work in this situation? |
#4
|
||||
|
||||
print_output is a vbulletin function and so you would need to actually include the function or the file where the function is defined in order for it to work.
|
#5
|
|||
|
|||
I noticed, when I saw this initial message, that you were asking why the page would not render, but there was not code listed to render your output. I guess I should have said something about the missing code and then I could have helped.
@Lynne of course is right -- Like always. Function print_output --> /includes/functions.php |
#6
|
||||
|
||||
Quote:
|
#7
|
||||
|
||||
Quote:
|
#8
|
|||
|
|||
I think the problem is that $db is a global variable used by vbulletin, and the code you added overwrites it. print_output() not only echoes the output, but it also does some final tasks such as updating the user's last activity time, so you probably want to use it if possible.
If you change all occurences of $db to something else in the code you added, it will probably work with print_output(). |
#9
|
|||
|
|||
Quote:
"I'm not worthy" |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|