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: