-2

My PHP is really terrible, so i've decided to post my error here.

Please see error and code below. I'm not sure why i am getting this error.

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: content

Filename: listings/index.php

Line Number: 37

 <div class="grid_4" id="refreshList"> <!--start MAIN REFRESH LIST-->
    <img src='<?=base_url()?>images/pixel.png' onload="xajax_test_function();"></img>
  </div><!--end MAIN REFRESH LIST-->

  <div class="clear"></div>

  <div class="grid_12"> <!--start MAIN INTRO PAR-->

  </div> <!--end MAIN INTRO PAR-->

  <div class="grid_12" id="div"> <!--start MAIN LISTINGS-->
  <div>
    <?=$content?>
  </div> <!--end MAIN LISTINGS-->
Momo6366
  • 21
  • 3

2 Answers2

0

You are trying to output a variable that is not declared or has a value earlier.

You can either put on a previous line something like <?php $content = ""; ?> or you can add a @ at your output statement and make it like this <?= @$content; ?>

In any case you are outputing a value $content so you need to assign something earlier as it doesnt exist or have a value.

Simos Fasouliotis
  • 1,383
  • 2
  • 16
  • 35
0

Yes, you forgot to declare the variable "content ='';".

You just add the line before <?php $content = ""; ?> or else you can use any of the below options to restrict the php error display conditionally.

<?php

// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>
Ashok
  • 128
  • 1
  • 8