I have a PHP script that I need to run as a cron job. However this script needs access to the WP API (get_pages()
, get_post_meta()
and get_permalink()
specifically). I've followed the instructions at http://codex.wordpress.org/Integrating_WordPress_with_Your_Website, but to no avail.
Code:
require_once('../../../wp-blog-header.php');
$args = array(
'child_of' => 2083
);
$pages = get_pages($args);
However when I run php -q this_file.php
from the command-line I get the following output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database Error</title>
</head>
<body>
<h1>Error establishing a database connection</h1>
</body>
</html>
Anyone have any thoughts/suggestions?