Well, from that bit of code I find impossible to tell where the problem is. Maybe if you paste more of it.. Maybe you have redundant spaces around the code..
This is the full function that keeps creating a blank empty space. WHAT THIS CODE DOES: It checks to see if a file exists (127.0.0.5_domain.txt), if it exists it loads the file and uses this data. If the file does not exit it fetches data from a database table and creates the file. function thisdomaincat($thishost="") { $domaincats = $thishost . "_domain.txt"; if(is_file($domaincats)) { $thisbranch = file_get_contents("$domaincats"); } else { $mypicsql = "SELECT tid FROM custom_categories where domain = '$thishost'"; $sql_result = mysql_query($mypicsql) or die("Couldn't execute query."); while ($row = mysql_fetch_array($sql_result)) { if($tcount > 0) { $thisbranch .= ",$row[tid]"; } else { $thisbranch .= "$row[tid]"; } $tcount++; } $writefile = fopen("$domaincats", 'w'); if (!$writefile) { echo "<p>Unable to open temporary file for writing.</p>"; echo "Update aborted"; exit(); } else { fwrite($writefile,$thisbranch); fclose($writefile); } } return $thisbranch; } PHP:
Thanks for the suggestions so far. This works but isn't useful $domaincats = "127.0.0.5" . "_domain.txt"; // I'm only changing domains here $domaincats = "127.0.0.4" . "_domain.txt"; PHP: This does not work ( because of the space), but would be useful $domaincats = trim($thishost) . "_domain.txt"; //or $domaincats = "$SERVER[HTTP_HOST]" . "_domain.txt"; PHP:
Not sure where the space is actually being outputted to the screen? Maybe you could use a str_replace....... $domaincats= str_replace(" ", "", $domaincats); PHP:
Just out of curiousity, let me get this straight. You comment that line of code out, and the space goes away? Is the space showing up in the HTML where this function is defined, or when it gets called?
it would be much more simple if marcel was showing an example of where the space appears along with the code of the function. As well, how the function is called would be interesting in order to solve the problem.