[ create a new paste ] login | about

Link: http://codepad.org/uB19UXhD    [ raw code | fork ]

rpantring - PHP, pasted on Oct 21:
<?php
$sql = "SELECT * FROM `wp_posts` WHERE `post_title` LIKE 'Home' LIMIT 1 ";
?>
<?php
$servername = "localhost";
$username = "wordpress";
$password = "123456";

try {
$conn = new PDO("mysql:host=$servername;dbname=wordpress", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

$statement = $conn->query($sql);
$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>';
print_r($rows);
echo '</pre>';

$content = $rows[0]['post_content'];
echo '<pre>';
echo ($content);
echo '</pre>';

require('wordpress/wp-blog-header.php');
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]&gt;', $content );
echo ($content);
?>


Create a new paste based on this one


Comments: