Results 1 to 5 of 5
  1. #1

    Default Wordpress database usage works, but causes problems.

    I've setup my site so that my most recent Wordpress blog is imported. It works, but it seems to cause some problems with Zen Cart. In include/modules I added the following code:

    Code:
    mysql_connect(localhost, $db_wpusername, $db_wppassword);
    @mysql_select_db($db_wpdatabase) or die("Unable to select database");
    
    //get data from database
    $quer123y = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY id DESC LIMIT 1"; 
    
    $query_result = mysql_query($quer123y);
    $num = mysql_numrows($query_result);
    
    //close database connection
    mysql_close();
    
    //assign data to variables
    $blog_date = mysql_result($query_result, 0, "post_date");
    $blog_title = mysql_result($query_result, 0, "post_title");
    $blog_content = mysql_result($query_result, 0, "post_content");
    
    //format date
    $blog_date = strtotime($blog_date);
    $blog_date = strftime("%b %e", $blog_date);
    
    //how many characters should be shown?
    $maxchars = 350;
    
    //strip out the html tags, such as images, etc...
    $blog_content = strip_tags($blog_content);
    
    //cut down the size of the post to 135 characters
    $blog_content = substr($blog_content, 0, $maxchars);
    $blog_content = $blog_content . "...";
    Obviously, I left out my db info and passwords! :)

    Anyway, it works, and I can use the blog info from the most recent post. But, it also seems to mess up some database calls on my site. The categories sidebox no longer shows any categories.... Is there a way to get info from my wordpress database without affecting calls to my zen cart database?

    Any help would be greatly appreciated. I am stumped.

  2. #2

    Default Re: Wordpress database usage works, but causes problems.

    This may have been a poorly worded title. I guess I need help from someone who has used a second database that is unrelated to ZenCart successfully in Zen Cart. Somehow, this usage is obviously causing a conflict, but I am not quite sure why. Any help would be greatly appreciated!

  3. #3

    Default Re: Wordpress database usage works, but causes problems.

    Ahh.... I think I got it! :) It seems I needed to specify a database. In essence I had shut down both database connections. So, I did the following:

    $newdb = mysql_connect(localhost, $db_wpusername, $db_wppassword);


    and

    mysql_close($newdb);


  4. #4

    Default Re: Wordpress database usage works, but causes problems.

    Spoke too soon. The problem persists. It is strange, but the only thing that seems to be affected is the categories sidebox. All of the categories disappear, but this doesn't happen every time. You have to refresh the page many times for it to happen. Then, once it happens, the categories all disappear from the sidebox for about 1 minute. You can surf the site, and everything works fine for that minute except for the category sidebox. Then, after a minute, everything is fine again.

    Strange....

  5. #5

    Default Re: Wordpress database usage works, but causes problems.

    I feel like I'm talking to myself. :)

    Anyway, I wasn't able to solve the problem, but I implemented the same thing a different way, so all is well. Still don't know why that caused a problem...

 

 

Similar Threads

  1. Changing text in quotes causes problems
    By johnnydakota in forum Basic Configuration
    Replies: 1
    Last Post: 10 May 2014, 03:01 AM
  2. Configure.php delete reinstall causes problems
    By stefanl in forum Upgrading from 1.3.x to 1.3.9
    Replies: 28
    Last Post: 8 Jun 2010, 02:01 PM
  3. WordPress problems
    By bakerman in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 16 Feb 2009, 02:41 PM
  4. ' in email adress causes problems
    By pglock in forum General Questions
    Replies: 9
    Last Post: 14 Jul 2006, 11:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg