Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-22 04:22:15

shilmy
Member
Registered: 2006-04-29
Posts: 49

How to retrieve and display mysql database content into TXP Article?

Hello,

I want to retrieve and display mysql database content into txp articles. What I’m trying to do is to display products related to the article.

I have tried this by using php code, but txp stop after rendering article and dispayed the products and do not render the rest of the page.

Can someone help?

Thank you.

Sjarief

Offline

#2 2007-08-22 06:35:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: How to retrieve and display mysql database content into TXP Article?

The products are within the txp default installed db?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2007-08-22 08:21:29

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to retrieve and display mysql database content into TXP Article?

No, the product tables reside in different mysql database, but in the same server.

Offline

#4 2007-08-22 16:22:28

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: How to retrieve and display mysql database content into TXP Article?

You will run in to a problem because txplib_db.php (all the txp db code) will only call mysql_select_db() when the DB class is created. When you connect to your other database, you are switching the active link away from the txp db, which results in failures for the rest of the page.

You should use mysql_select_db( $DB->link ) or $DB = new DB to reset the connection back to the txp db.

Offline

#5 2007-08-22 21:59:36

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to retrieve and display mysql database content into TXP Article?

I put

$DB = new DB

just before </txp:php>, and it works.

Thank you.
Sjarief

Offline

Board footer

Powered by FluxBB