0

I have the follow for my wordpress plugin:

<body>
    <h1>My example site</h1>

    <?php
      global $wpdb;
      //require_once('../../../wp-load.php');

      $posts = $wpdb->get_results("SELECT * FROM red_reservacion;");

      foreach($posts as $row)
      {
      }

    ?>

</body>

That in my .php file.

But when the page is rendered in my browser displays:

enter image description here

I think the problem is the greater than symbol

Exist a way to fix it?

Benjamin RD
  • 11,516
  • 14
  • 87
  • 157

1 Answers1

0

Supposedly, your short tags is turned off so PHP does not recognize just <? and by the way, You may also move all the PHP Code to the very Top of the Script to see if it helps... You might try this instead:

    <?php  //<== JUST ADD php AFTER <? 

        //require_once('../../../wp-load.php');
        // DO ALL THE PHP OPERATIONS OUTSIDE THE HTML BLOCK 
        // PERHAPS AT THE VERY TOP OF YOUR SCRIPT TO SEE IF IT HELPS...
        global $wpdb;
        $posts  = $wpdb->get_results("SELECT * FROM red_reservacion");
        $output = "";

        foreach($posts as $row){
            $output .= "<h2 class='h2-class'>{$row->post_title}</h2>" . PHP_EOL;
            $output .= "<div class='div-class'>{$row->post_content}</div>" . PHP_EOL;
            // CONTINUE BUILDING UP YOUR OUTPUT STRING HERE...
        }
    ?>

        <body>
            <h1>My example site</h1>
            <?php echo $output; ?>
        </body>
Poiz
  • 7,611
  • 2
  • 15
  • 17