Tabs causing errors

Reply

Join Date: Jun 2005
Posts: 2
Reputation: chrziz is an unknown quantity at this point 
Solved Threads: 0
chrziz chrziz is offline Offline
Newbie Poster

Tabs causing errors

 
0
  #1
Jun 13th, 2005
I've been getting errors by putting tabs in my script to make it a little easier to read and more organized. As soon as I take the tabs out, the errors go away but the script is very ugly. I even tried using 4 spaces in place of the tabs and that did not work.

Here is the original code after I replaced the tabs with spaces:
  1. while($category = _fetchobj($col1_category_query)) {
  2. $col1_subcat_query = "SELECT id,name FROM categories WHERE parentid = '$category->id'";
  3. $col1_subcat_result = _query($col1_subcat_query);
  4. $subcat_list = "<b>Sub-Categories:</b><br>";
  5. while($subcat = _fetchobj($col1_subcat_result)) {
  6. $subcat_list .= <<<EOT
  7. <b><a href="viewcat.php?id=$subcat->id">$subcat->name</a></b><br>
  8. EOT;
  9. }
  10. $col1_link_query = "SELECT id,name,parentcat,category FROM links WHERE parentcat = '$category->id' LIMIT 0,5";
  11. $col1_link_result = _query($col1_link_query);
  12. $link_list = "<i>First 5 Sites:</i><br>";
  13. while($link = _fetchobj($col1_link_result)) {
  14. $link_list .= <<<EOT
  15. <a href="go.php?id=$link->id">$link->name</a><br>
  16. EOT;
  17. }
  18. $col1 = <<<EOT
  19. <table border="0" width="100%" id="table1" cellspacing="0" style="border: 1px solid #DADADA"><tr><td align="center" bgcolor="#DADADA">$category->name</td></tr><tr><td align="center" bgcolor="#F8F8F8">$subcat_list<br>$link_list</td></tr></table>
  20. EOT;
  21. }

If I take the tabs out, it looks like this, and get no errors:
  1. while($category = _fetchobj($col1_category_query)) {
  2. $col1_subcat_query = "SELECT id,name FROM categories WHERE parentid = '$category->id'";
  3. $col1_subcat_result = _query($col1_subcat_query);
  4. $subcat_list = "<b>Sub-Categories:</b><br>";
  5. while($subcat = _fetchobj($col1_subcat_result)) {
  6. $subcat_list .= <<<EOT
  7. <b><a href="viewcat.php?id=$subcat->id">$subcat->name</a></b><br>
  8. EOT;
  9. }
  10. $col1_link_query = "SELECT id,name,parentcat,category FROM links WHERE parentcat = '$category->id' LIMIT 0,5";
  11. $col1_link_result = _query($col1_link_query);
  12. $link_list = "<i>First 5 Sites:</i><br>";
  13. while($link = _fetchobj($col1_link_result)) {
  14. $link_list .= <<<EOT
  15. <a href="go.php?id=$link->id">$link->name</a><br>
  16. EOT;
  17. }
  18. $col1 = <<<EOT
  19. <table border="0" width="100%" id="table1" cellspacing="0" style="border: 1px solid #DADADA"><tr><td align="center" bgcolor="#DADADA">$category->name</td></tr><tr><td align="center" bgcolor="#F8F8F8">$subcat_list<br>$link_list</td></tr></table>
  20. EOT;
  21. }

My scripts have always done this so I usually just make it ugly and remove the tabs just so I don't get the error.

I use the editor Notepad++ and have tried copying the code into Notepad and then saving the file using notepad and that doesn't work either so I guess it's not Notepad++.

The error I get is:
Parse error: parse error, unexpected $ in /index.php on line 102 (102 is last line of the script that only has the closing tag ?>)

Can someone please help me?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2
Reputation: chrziz is an unknown quantity at this point 
Solved Threads: 0
chrziz chrziz is offline Offline
Newbie Poster

Re: Tabs causing errors

 
0
  #2
Jun 13th, 2005
Figured it out!

Spaces and tabs are forbidden in front of a closing marker!

I just had to take the spaces out before the EOT;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC