Welcome Guest, Not a member yet? Register   Sign In
php parse errors
#1

[eluser]richzilla[/eluser]
What would cause a php parse error in a view file? ive checked all of my php tags and theyve all been closed properly, and my html all looks good, yet i consistently get a parse error for the last line of my view. I Thought it might be white space after the closing div tag, but no, still no luck. I have just switched to wampserver and a windows box, and the problem only occurs here, on my linux comp all is well. If anybody has any ideas (or a better lamp stack for windows, wampserver has caused me no end of headaches) id greatly appreciate the assist. The offending code:
Code:
<div class="grid_10 omega" id="content">
            <div>
                <h2>News</h2>
                <h4>Existing</h4>
            </div>
            <table id="newsTable" class="tablesorter">
                <thead>
                    <tr>
                        <th>Title</th>
                        <th>Tagline</th>
                        <th>Posted By</th>
                        <th>Posted</th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                    &lt;?php foreach ($posts as $indpost) : ?&gt;
                        <tr>
                        <td class="wide">&lt;?php echo $indpost->title; ?&gt;</td>
                        <td class="wide">&lt;?php echo $indpost->tagline; ?&gt;</td>
                        <td class="wide">&lt;?php echo $indpost->userName; ?&gt;</td>
                        <td class="wide">&lt;?php echo $indpost->postDate; ?&gt;</td>
                        <td class="narrow">&lt;?php echo anchor('news/delete/'.$indpost->id,'Delete'); ?&gt;</td>
                        <td class="narrow">&lt;?php echo anchor('news/view/'.$indpost->id.'?TB_iframe=true&height=400&width=800','View',array('class' => 'thickbox')); ?&gt;</td>
                        </tr>
                    &lt;? endforeach; ?&gt;
            </table>
            
            <div>
                
                
                <h4>Add New</h4>
            </div>

            &lt;?php echo form_open('news/add',array('class' => 'form form_320')); ?&gt;
            
                <div>
                    &lt;?php echo form_error('title'); ?&gt;
                    <label for="title">Title: </label>
                    &lt;input type="text" name="title" value="&lt;?php echo set_value('title'); ?&gt;" class="newsinput"/&gt;
                </div>
                
                <div>
                    &lt;?php echo form_error('tagline'); ?&gt;
                    <label for="tagline">Tagline: </label>
                    &lt;input type="text" name="tagline" value="&lt;?php echo set_value('tagline'); ?&gt;" class="newsinput" /&gt;
                </div>
                
                <div>
                    &lt;?php echo form_error('news_content'); ?&gt;
                    <label for="content">Content: </label>
                    &lt;textarea name="news_content" value="&lt;?php echo set_value('news_content'); ?&gt;" class="newsinput" style="height: 100px;"&gt;&lt;/textarea>
                </div>
                
                <div>
                    &lt;input type="submit" value="Submit"/&gt;&nbsp;&lt;input type="reset" value="Reset" /&gt;
                </div>
                
                &lt;?php if ($this->session->flashdata('status')) { echo $this->session->flashdata('status'); } ?&gt;

            &lt;?php echo form_close(); ?&gt;
            
            

</div>
</div>

The error comes up on line 66 (the last one)
Again any help would be appreciated.
#2

[eluser]Flemming[/eluser]
Your code looks fine to me, and the fact that it works on your linux server does suggest that the problem isn't with your code. Have you tried stripping everything except a simple
Code:
<div>hello</div>
from your view and seeing if it still gives you a parse error? (i presume you ARE loading the view from a controller?)
#3

[eluser]BrianDHall[/eluser]
For a different WAMP stack you could go with XAMPP, but I ended up going back to WampServer because I use 64-bit Vista and it works when XAMPP won't.

I'm thinking your problem could be a CR/LF sort of issue being interpretted one way on linux and being eaten by windows. If you follow Flemming's advice and it still gives an error, create a new text file on your windows system and save it as your view with just something simple like hello as above.

If there is still an error I would think it is something going wrong probably on your controller (a missing bracket can produce odd behavior sometimes. I'd test the same view giving the error in a controller function with nothing but the load view - if it still causes a parse error and it isn't the view, you might try creating a quick blank controller and testing it there. That would narrow it down.

Basically the trick would be commenting out blocks of code in your controller to see when the parse error disappears.
#4

[eluser]John_Betong[/eluser]
&nbsp;
Before trying the sledge hammer approach which I am sure will work, try replacing this line of code:
Code:
// OLD LINE OF CODE
    &lt;? endforeach; ?&gt;

  // NEW LINE OF CODE
    &lt;?php endforeach; ?&gt;
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB