0

Unfortunately my start was not very good at the time. But this time I have PHP Code problem.

This code is available. In line 2 with "<" it means that it can not be parsed. What am I doing wrong?

<?php if (!wp_is_mobile()) {
   <div id="content">
                <!-- Posts anzeigen -->
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <!-- Datumsheader -->
                        <p class="dateheader"><?php the_date('l, j. F Y'); ?></p>
                    <!-- Posttitel -->
                        <a class="posttitle" href="<?php the_permalink() ?>">
                        <h2><?php the_title(); ?></h2>
                        </a>
                    <!-- Posttext -->
                        <div class="entry">
                            <?php the_content(); ?>
                        </div>
                        <p style="text-align:right;"><a href="<?php the_permalink(); ?>#comments" title="Kommentare zu '<?php the_title(); ?>'"><?php comments_number('Noch kein Kommentar','1 Kommentar','%Kommentare'); ?></a></p>
                        <hr class="postende" />
                <?php endwhile; ?>
                <!-- Posts anzeigen Ende-->

                <!-- aeltere und neuere Posts anzeigen / Seitennavigation -->
                    <p align="center">
                    <?php previous_posts_link('&laquo;Neuere Eintr&auml;ge') ?> | 
                    <?php next_posts_link('&Auml;ltere Eintr&auml;ge &raquo;') ?>
                    </p><!-- Seitennavigation Ende -->

            <?php endif; ?>
            <hr />
        </div>
            <div id="footer1">
                <div id="spalte1">
                    <h3>Suche</h3>
                    <p>
                    <form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                       <input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
                       <input type="submit" id="search_submit" value="Suchen" />
                    </form>
                    </p>
                    <h3>ganzjährige Blogprojekte</h3>
                    <p>
                        <a href="http://tweedandgreet.de/12coloursofhandmadefashion/" target="_blank">12 Colors of Handmade Fashion</a>  (jeden Monat eine Farbe, zu der genäht werden darf) <br />
                        <a href="http://die-photographin.de/2016/12/increase-creativity-challenge-2017/" target="_blank">Increase Infinity</a> (jeden Monat eine Farbe, zu der gebloggt werden soll)<br />
                        <a href="https://vom-landleben.de/blogprojekt/fotoprojekt17/" target="_blank">Fotoprojekt17</a> (jeden         Monat ein Thema, zu dem fotografiert werden kann)<br />
                        <a href="https://tonari.wordpress.com/category/rost-parade/" target="_blank">Fotoprojekt: Rostparade</a> (immer am letzten Tag des Monats Rostfotos online stellen) <br />
                        <a href="http://fuenfzig-millimeter.de/projekt-graustufe-allgemeine-informationen/" target="_blank">Fotoprojekt: Graustufen</a> (jeden Monat ein Thema, zu dem Schwarz-weiß-Fotos gemacht werden sollen)<br />
                        <a href="https://heutemachtderhimmelblau.com/bunt-ist-die-welt/" target="_blank">Fotoprojekt: Bunt ist die Welt</a> (Jeden Sonntag ein Thema, zu dem für fünf Tage fotografiert werden darf)<br />
                        <a href="http://kathastrophal.de/aus-diyyourcloset-wird-naehdirwas" target="_blank">Näh dir was</a> (Jeden Monat ein neues Nähthema, zu dem man etwas für sich nähen soll)<br />
                        <a href="http://www.whatinaloves.com/2017/01/bloggerproject-lets-cook-together-2017.html" target="_blank">Lets cook toghether</a> (Jeden Monat ein Thema, zu dem gekocht/gebacken und ab dem 10. Tag des Monats verlinkt werden darf)<br />
                        <a href="http://www.tastesheriff.com/die-gemuese-expedition/" target="_blank">Die Gemüse-Expedition</a> (Jeden Monat ein Gemüse, das in der Küche verarbeitet werden soll)<br />

                    </p>
                </div>
                <div id="spalte2">
                    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
                    <?php endif; ?>
                </div>
                <div id="clear"></div>
            </div>
        </div>

} ?><!-- Ende Destop -->
        <div id="sidebar">
            <?php get_sidebar(); ?><!-- sucht sidebar.php und fügt den Code hier ein -->
        </div>
        <div id="footer2"><?php get_footer(); ?><!-- sucht footer und fügt den Code hier ein --></div>
    </div>
</body>
</html>

Unfortunately I own hardly any programmer knowledge and the code output would like to realize a forum user with me.

I hope you can help me so.

Thanks in Advance.

5
  • 1
    The easiest way to resolve syntax errors is to delete things until they go away, then carefully restore bits of code until they re-emerge. I hope you're using a version control system to track your changes, that makes this process even more efficient. It's also a good idea to have a syntax-highlighting editor, it can usually call out mistakes in a way that's difficult to overlook. Commented Jul 21, 2017 at 1:43
  • @tadman, it would be much more effective to move around a exit; statement to see if you code runs up to that point. Commented Jul 21, 2017 at 1:50
  • @Jeppesen Also a good idea. There's a few tricks that can save a ton of time. Commented Jul 21, 2017 at 2:04
  • @tadman, Thanks for the tip. This wrong code had me a user of my forum showed. I myself work with the Phase 5 editor. I have a version control system but in the Github repositories of mine. In PHP, I do not even program anything, but I deal with it sometimes when the need exists. Commented Jul 21, 2017 at 3:03
  • Sounds like you've got all the right tools, so that's good. Commented Jul 21, 2017 at 15:37

1 Answer 1

2

You forgot to close the PHP tag at line 2 before you start the HTML again

<?php if (!wp_is_mobile()) { ?>

and you forgot to open the PHP tag at line 67 ...

<?php
} 
?><!-- Ende Destop -->

In order to avoid this, make sure you have a good PHP IDE that has an integrated code syntax checker. It will point out right away when something as fundamental is missing

Sign up to request clarification or add additional context in comments.

2 Comments

@ Patrick Simard, Thanks for the great help. In advance, I checked the above PHP code with the online checkers and since I had assumed that which PHP tags are missing. Now I know more about it.
What do you use to compose your PHP code? You should take a look at PHPStorm. It will tell you as you compose that you forgot something important lol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.