Goal: Update wordpress post with PHP cli
< ?php
$con = mysql_connect("localhost","root","[redacted]");
if (!$con)
{
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("wordpress")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$myfileText = mysql_real_escape_string(file_get_contents('./code_for_wordpress.html',true));
$sql = "UPDATE `[your_instance_prefix]_posts` SET `post_content` = '$myfileText' WHERE `ID` like '1397';";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
mysql_close($con);
?>
Tags:
MySQL,
mysql set post_content,
mysql set post_content php,
mysql update,
php cli mysql update variable,
php mysql,
php mysql scripts,
php mysql update,
php mysql update variabe howto,
php mysql update variable,
php update insert special characters