EllisLab text mark
Advanced Search
     
Starting out; strange issues (single-line comments)
Posted: 01 October 2012 04:09 PM   [ Ignore ]
Joined: 2012-10-01
3 posts

I’ve installed CI and it went smoothly, however as I’m going through the tutorial, I’m getting strange errors. Long story short, single-line quotes (both // and #) will cause the script to throw a syntax error:

Parse error: syntax error, unexpected $end in /home/mysitename/ci/application/controllers/pages.php on line 1

i.e., from the Static Pages tutorial, this bombs out:

$data['title'ucfirst($page); // Capitalize the first letter 

...while this does not:

$data['title'ucfirst($page); /* Capitalize the first letter */ 

I’ve written plenty of from-scratch PHP and never encountered this problem. In fact, I have scripts with single-line comments running on my host as we speak.

The only thing I can think of as possibly being an issue: I don’t have CI running out of /public_html (as you may have noticed above). I installed /system and /application under /home/mysitename/ci (for security reasons as suggested in the installation instructions). I set the path variables in index.php accordingly (actually, I’m referring to it as index_ci.php). Could this configuration be causing some funkiness?

My host is running PHP 5.3.17, so I doubt it’s a version issue. I’m getting other weird issues, but I’ll leave it at this for now. Any light anyone can shed would be greatly appreciated; I’m excited to get started with CI but right now I feel like I’m tripping on my shoelaces as soon as the starter pistol goes off!

 
Posted: 01 October 2012 04:31 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-12-19
612 posts

Are you by chance using short php tags on your document:

<?=
or
<? 

 

 Signature 

CI 2.1.3, Linux, LAMP. We also like Gold and Silver…
Blame the hammer, it is obviously the guilty party…
User Guide? Nobody told me there was a User Guide!

 
Posted: 01 October 2012 04:39 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-10-01
3 posts

Nope… I’m using:

<?php
...
?> 

 

 
Posted: 01 October 2012 04:44 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

Do you have the Directory-directive configured properly? Otherwise I could only imagine some faulty php.ini configuration (even though I never experienced that problem).

Or you have some strange white spaces in your file?

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess

 
Posted: 01 October 2012 05:14 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-26
122 posts
pointfive - 01 October 2012 04:39 PM

Nope… I’m using:

<?php
...
?> 

never close the php document. just leave it “open”

 

 
Posted: 02 October 2012 10:01 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2012-10-01
3 posts
PhilTem - 01 October 2012 04:44 PM

Or you have some strange white spaces in your file?

This looks like it was the problem. It seems I was working with a copy of a file which uses “line feed” instead of “carriage return”. It doesn’t like single-line comments with line feed for some reason. Weird.

Anyway, thanks for the help!