WordPress.org

Ready to get started?Download WordPress

Forums

mysql_close issue (1 post)

  1. Dubai Web Design - incirclemedia.com
    Member
    Posted 1 year ago #

    I have two wp installed on my server, one is my website and 2nd is blog. I want to display two recent posts from blog to website through bellow code.

    It is working perfect but I think mysql_close() is making issue to close database. because I am calling footer of my website but it is showing posts from blog. But on inner pages it is displaying website footer.

    How can i fix it?

    <?php
    	$db_username = '#######';
    	$db_password = '#######';
    	$db_database = '#######';  
    
    	$blog_url = 'http://www.#######.com/#######/blog/'; //base folder for the blog. Make SURE there is a slash at the end  
    
    	//connect to the database
    	$con = mysql_connect(localhost, $db_username, $db_password);
    	@mysql_select_db($db_database) or die("Unable to select database");
    	$query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY id DESC LIMIT 2";
    
    	$query_result = mysql_query($query);  
    
    	while($row = mysql_fetch_array($query_result))
        {
        ?>
    
        <div class="blog_cont"> <a>"><b><?php echo $row['post_title'] ?></b></a><br clear="all" />
          <span><?php if (strlen($row['post_content']) > 40) { echo substr($row['post_content'], 0, 120) . '...'; } ?></span> <a>">Read More ยป</a> </div>
        <?php }
    	  @mysql_close($con);
    	?>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Dubai Web Design - incirclemedia.com
  • This topic is not resolved
  • WordPress version: 3.5