How to get the site name in drupal 6?
In both Drupal 6 and Drupal 7, you can use variable_get.
The CMI initiative will likely deprecate this function in Drupal 8.

$name = variable_get('site_name', '');


Notice the blank '' at the end, which is the "default" value, in case a variable isn't defined.