terryl Posted March 28, 2008 Share Posted March 28, 2008 Hi, I a beginner and have been doing a lot of reading trying to fix my problem. I am using a password_protect.php type script which requires a line of php code to be added to the first line of any page you want to protect with the password. Everything works great except one little annoyance, when I view the page in a browser there is an extra space at the very top of the page. When I remove the php code from the first line the space goes away. I am using dynamic web templates in expression web, so when this happens, my entire template is pushed down one line on all the pages I want to use the password_protect.php script on... It is very annoying because when you click on the buttons after entering a password, the buttons are not in the same place for all pages. Is there any way to get around having php add that space to the top of my pages? Link to comment https://forums.phpfreaks.com/topic/98391-extra-line-space-added-at-top-of-web-page-when-php-script-is-first-in-code/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 28, 2008 Share Posted March 28, 2008 It sounds like either when you are including the code you have some white space before or after it or the actual file you are including as some white space before or after the <?php ?> tags or the php code itself is outputting some white space. Post the first part of your page to show how you are including the php code and then post the contents of the password_protect.php file. Link to comment https://forums.phpfreaks.com/topic/98391-extra-line-space-added-at-top-of-web-page-when-php-script-is-first-in-code/#findComment-503526 Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Share Posted March 28, 2008 Don't post a part that looks like this though: <?php $conn = mysql_connect("localhost", "test_db", "******") or die(mysql_error()); mysql_select_db("test_db",$conn) or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/98391-extra-line-space-added-at-top-of-web-page-when-php-script-is-first-in-code/#findComment-503550 Share on other sites More sharing options...
terryl Posted March 28, 2008 Author Share Posted March 28, 2008 I think I figured it out, I just put some HTML ingnore tags around the php script. Here is what the begining of my code looked like at first: <?php include("C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\password_protect_inviteonly.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <!-- #BeginTemplate "terrylus.dwt" --> so I just put <!-- phpscript --> around the php scirpt and it got rid of the space. Its weird that the browser printing that as extra space, but what ever. I made this site with tables. I have one big table with 2 columns and 3 rows. My second row keeps falling down a few spaces when I have files on a page to be downloaded. It is not very good coding, but the only way I could get around it was to put a bunch of "p" tags down the page (like 20) and justify them left. It is my first site so I'm just learning as I go. terryl.us if you wanna check it out to see a little better what I am talking about. It is not the best right now, but it is working the way I intended it to... so far. Thx for help though guys! Link to comment https://forums.phpfreaks.com/topic/98391-extra-line-space-added-at-top-of-web-page-when-php-script-is-first-in-code/#findComment-503642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.