php mysql update variable

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);
?>

Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>