Display recent posts on another site

I’m not sure what you’re doing with the above script, but here are some random suggestions:

  • Avoid using the root user, for security reasons create another database user with less powers.
  • Avoid using deprecated mysql_* calls.
  • Use WP_Query() or get_posts() instead of hardcoded SQL queries.
  • Use global $wpdb object if you really must use hardcoded SQL queries.
  • Remove the <?php?> spam
  • Try doing this within WordPress itself, instead of creating an extenral script.php file.
  • You don’t seem to be using the $blog_url, $query_result, $num_rows, … variables.
  • There are other ways like WP REST API, XML-RPC, RSS, JSON