Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-03 16:18:48

msteinruck
Member
Registered: 2004-07-14
Posts: 44

4.0.2 Error Pages and custom DB call

I copied and pasted my template into the error_default template and everything seems to work fine except that I have a custom database call in there to pull the navigation out of the links table in a certain way. This DB call works fine for every page on the rest of the site, but not on the error_default template. Is that referencing things in a different way that I’m not aware of? I thought it worked just like any other template except that it’s for error pages.

thanks

Offline

#2 2005-11-03 19:43:29

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: 4.0.2 Error Pages and custom DB call

Well, the error page does not have a section. That’s one difference.

But why don’t you post your

custom database call in there to pull the navigation out of the links table in a certain way

and explain what it used to return, and what it is returning now.

Offline

#3 2005-11-03 20:08:43

msteinruck
Member
Registered: 2004-07-14
Posts: 44

Re: 4.0.2 Error Pages and custom DB call

It’s just a normal database connection with an SQL statement that pulls a certain set of navigation links. It returns an error that says that a connection cannot be made with the database. A friend of mine had the same problem.

Offline

#4 2005-11-04 00:26:19

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error Pages and custom DB call

We’ll need to see the code.

Also, what exactly is the condition that’s causing the error template to be displayed?


Alex

Offline

#5 2005-11-04 20:49:03

msteinruck
Member
Registered: 2004-07-14
Posts: 44

Re: 4.0.2 Error Pages and custom DB call

Here’s my code:

<code>

<a href=”#events” title=“Skip Navigation” class=“hidden”>Skip Navigation</a>
<ul>
<?php

$dbcnx = @mysql_connect(‘all login info here’); if (!$dbcnx) { exit(‘<p>Unable to connect to the ‘ . ‘database server at this time.</p>’); } // Select the textpattern in the database if (!@mysql_select_db(‘namehere’)) { exit(‘<p>Unable to locate the ‘ . ‘database at this time.</p>’); }

$gLink = @mysql_query(“SELECT id, linkname, url, category, description FROM txp_link WHERE category = ‘globalNav’ ORDER BY ‘linksort’ ASC”);

if(!$gLink) { exit(‘<p>Error performing query’ . mysql_error() . ‘ </p>’);
}

while ($getId = mysql_fetch_array($gLink)) {
$navDesc = $getId[‘description’];
$navName = $getId[‘linkname’];
$navUrl = $getId[‘url’];
$navCat = $getId[‘category’];
if($gLink) {
echo “<li id=\“m$navDesc\”><a href=\”$navUrl\”>”.$navName.”</a></li>”;

}
}
mysql_close();
?>
</ul>

</code>

Offline

#6 2005-11-04 21:33:19

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: 4.0.2 Error Pages and custom DB call

msteinruck: Textpattern does all the hard work for you. Try the following and see if it makes any difference.

Offline

#7 2005-11-05 00:18:57

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error Pages and custom DB call

mysql_close();

There’s your problem – you’ve pulled the rug out from underneath Textpattern.

As Mary says, Textpattern already handles the mysql connection, and provides a bunch of nice and easy database access functions for you to use.


Alex

Offline

Board footer

Powered by FluxBB