You have the right idea, but your implementation needs to be fixed:
$sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr
FROM $dbsql WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day )
GROUP BY dnr,tdr ORDER BY tdr";
$result = mysql_query($sql);
$day_names = array();
$unique_hits = array();
while ($row = mysql_fetch_assoc($result)) {
$day_names[] = $row['dnr'];
$unique_hits[] = $row['cnt'];
}
$title = "Unique Hits/Day";
$day_name_label = "Day";
$unique_hit_label = "Unique Hits";
Now you can use the $day_names and $unique_hits arrays right away. There is no need to have to go through strings.
You might note that these arrays have much better names than $x and $y. $x and $y most likely applies for your graph, but before you actually translate the data into graphical form, use names that are appropriate to your data, not the graph as one particular way of representing the data.