Post by imwahdiah » Thu Jun 21, 2012 9:25 am

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>

Newbie

Posts

Joined
Sat May 26, 2012 11:08 am

Post by Avvici » Sun Jun 24, 2012 9:50 am

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.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by straightlight » Sun Jun 24, 2012 8:20 pm

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

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Avvici » Sun Jun 24, 2012 8:32 pm

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.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by straightlight » Sun Jun 24, 2012 8:48 pm

Correct. Which is why two solutions was provided instead of one from my previous post.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Avvici » Sun Jun 24, 2012 11:54 pm

Does mean we are supposed to make up and hug it out? I don't like hugging. ::)

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC
Who is online

Users browsing this forum: No registered users and 5 guests