mysql_close issue
-
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 = 'https://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); ?>
- The topic ‘mysql_close issue’ is closed to new replies.