Welcome Guest, Not a member yet? Register   Sign In
Problems in views when reinstall appserv
#1

(This post was last modified: 05-18-2020, 10:46 PM by Edel.)

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




Theme © iAndrew 2016 - Forum software by © MyBB