Page 1 of 1

Integrating Wordpress: Error establishing a database

Posted: Thu Jun 21, 2012 9:25 am
by imwahdiah
Hi Guys,
I am having trouble with displaying recent post preview from my wordpress to my opencart site.
I've included this code to my site, however i received an error message saying "Error establishing a database connection". Anyone? Thanks in advance

Code: Select all

<ul>
  <?php require($_SERVER['DOCUMENT_ROOT'] . '/wp/wp-load.php'); query_posts('showposts=3');  if 

(have_posts()) : while (have_posts()) : the_post(); ?>
  <li>
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <span>Posted on <?php the_time('l jS F, Y') ?></span><br />
    <?php the_excerpt(); ?>
  </li>
  <?php endwhile; else: echo "no posts"; endif; ?>
  <?php wp_reset_query(); ?>
</ul>

Re: Integrating Wordpress: Error establishing a database

Posted: Sun Jun 24, 2012 9:50 am
by Avvici
Well, exactly what page are you trying to display it on? You need to connect to either the WP database or Open Cart database with a DB connect script.

Re: Integrating Wordpress: Error establishing a database

Posted: Sun Jun 24, 2012 8:20 pm
by straightlight
There are two known possibilities with database connection, in this case;

1 - WP Connect API from the WordPress contribution website which does not handle OpenCart connection by default though.
2 - With this one which can handle any type of connections from databases without XML but still requires manual but only very minimal establishment for both parties to be reunited: http://www.opencart.com/index.php?route ... on_id=3913

Re: Integrating Wordpress: Error establishing a database

Posted: Sun Jun 24, 2012 8:32 pm
by Avvici
straightlight wrote:There are two known possibilities with database connection, in this case;

1 - WP Connect API from the WordPress contribution website which does not handle OpenCart connection by default though.
2 - With this one which can handle any type of connections from databases without XML but still requires manual but only very minimal establishment for both parties to be reunited: http://www.opencart.com/index.php?route ... on_id=3913
I wasn't suggesting he connect to WP on WP with the OC DB connect.

Re: Integrating Wordpress: Error establishing a database

Posted: Sun Jun 24, 2012 8:48 pm
by straightlight
Correct. Which is why two solutions was provided instead of one from my previous post.

Re: Integrating Wordpress: Error establishing a database

Posted: Sun Jun 24, 2012 11:54 pm
by Avvici
Does mean we are supposed to make up and hug it out? I don't like hugging. ::)