Zen Cart Logo
Forums / General Questions / Wordpress database usage works, but causes problems.

Wordpress database usage works, but causes problems.

Locked

Views: 1,048

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
18 Jul 2008, 8:18 AM
#1
srturner47 avatar

srturner47

Zen Follower

Join Date:
Oct 2007
Posts:
385
Plugin Contributions:
0

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:

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. :frusty:

18 Jul 2008, 4:44 PM
#2
srturner47 avatar

srturner47

Zen Follower

Join Date:
Oct 2007
Posts:
385
Plugin Contributions:
0

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!

18 Jul 2008, 5:21 PM
#3
srturner47 avatar

srturner47

Zen Follower

Join Date:
Oct 2007
Posts:
385
Plugin Contributions:
0

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);

:clap:

18 Jul 2008, 8:27 PM
#4
srturner47 avatar

srturner47

Zen Follower

Join Date:
Oct 2007
Posts:
385
Plugin Contributions:
0

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....

19 Jul 2008, 3:03 AM
#5
srturner47 avatar

srturner47

Zen Follower

Join Date:
Oct 2007
Posts:
385
Plugin Contributions:
0

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...