Using the $wpdb in wordpress to run SQL commands
Try this instead:
<?php
include_once("wp-config.php");
include_once("wp-includes/wp-db.php");
$sql = "UPDATE tablename SET column1='testdata' WHERE id=1";
$results = $wpdb->get_results($sql);
You need to include the files where the database object is defined.
The get_results() and query() functions only work when combined with the $wpdb global.
For example:
global $wpdb;
$wpdb->get_results($sql);