• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems in views when reinstall appserv

#1
Hello everyone. I am developing in CI 4. I changed the appserv version recently.
I saved my project from the old www folder and copied it into the new www in my new installation. but when I send variables to the view it doesn't recognize them.
PHP Code:
$result->adverts $adverts//ad list
$dat['result'] = $result;
$view = \ Config\Services::renderer();
$view->setData($dat);
$data['previews'] = $view->render('tools/previews'); 

In my view : APPPATH/Views\tools\previews.php
Code:
<?    
print_r($result); //line 2
print_r($result->adverts);//line 3
foreach($result->adverts as $advert){
        $time = Time::parse($advert->date);        
?>
    <div class=" preview col-lg-2 col-md-2 col-sm-3 col-xs-12">
            <div class="box">
                <a href="<?=$advert->getHref(NULL, $m_category)?>"> //line 9

the error that return is "ErrorException, Undefined variable: advert" in APPPATH/Views\tools\previews.php at line 9
the lines 2 and 3 don't print anything.

why if lines two an three does not print anything code is executed inside the foreach

I have not changed anything within my project. I suppose the problem is related to some php or apache configuration.
php 7.3.10

Thanks in advance.
Reply

#2
My friends. I solved the problem by enabling short-open-tag in the php.ini file
Reply

#3
(05-22-2020, 11:28 AM)Edel Wrote: My friends. I solved the problem by enabling short-open-tag in the php.ini file

Hi, you should fix those problems instead. Changing your <? into <?php, that's just a bad practice requiring to have that on.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.