Following program giving output properly..but showing some warning

:slight_smile:

<?php $cols_inc=0; $data[]=array(); $data[$cols_inc]['VALUE']=20; $data[$cols_inc]['MAX_CHAR']=5; $data[$cols_inc]['POS']; $data[$cols_inc]['TFLAG']=false; $cols_inc++; $data[$cols_inc]['VALUE']=50; $data[$cols_inc]['MAX_CHAR']=55; $data[$cols_inc]['FORMAT']='N'; $cols_inc++; $data[$cols_inc]['VALUE']=100; $data[$cols_inc]['MAX_CHAR']=15; $data[$cols_inc]['FORMAT']='N'; for($c=0;$c<=count(data);$c++) { echo $data[$c]['VALUE'] ; } ?>

You should include the errors/warnings/notices you are getting when adding code here.

[code]Notice: Undefined index: POS in /srv/www/test/public/pankajdurve/index.php on line 8 Call Stack: 0.0040 124764 1. {main}() /srv/www/test/public/pankajdurve/index.php:0

Notice: Use of undefined constant data - assumed ‘data’ in /srv/www/test/public/pankajdurve/index.php on line 21 Call Stack: 0.0040 124764 1. {main}() /srv/www/test/public/pankajdurve/index.php:0 20

Notice: Use of undefined constant data - assumed ‘data’ in /srv/www/test/public/pankajdurve/index.php on line 21 Call Stack: 0.0040 124764 1. {main}() /srv/www/test/public/pankajdurve/index.php:0 50

Notice: Use of undefined constant data - assumed ‘data’ in /srv/www/test/public/pankajdurve/index.php on line 21 Call Stack: 0.0040 124764 1. {main}() /srv/www/test/public/pankajdurve/index.php:0[/code]

Which one of these are you having trouble with resolving?

You are definitely not getting “WARNINGS” and proper output, you are getting errors.

Basically you just have a bunch of typos and missing arguments.

Hint read what the errors are saying they will help you out.

Anyways - here’s a fix:

[php]<?php

$cols_inc=0;
$data = array("");

$data[$cols_inc][‘VALUE’]=20;
$data[$cols_inc][‘MAX_CHAR’]=5;
$data[$cols_inc][‘POS’]= “Need a Value Here”;
$data[$cols_inc][‘TFLAG’]=false;

$cols_inc++;
$data[$cols_inc][‘VALUE’]=50;
$data[$cols_inc][‘MAX_CHAR’]=55;
$data[$cols_inc][‘FORMAT’]=‘N’;

$cols_inc++;
$data[$cols_inc][‘VALUE’]=100;
$data[$cols_inc][‘MAX_CHAR’]=15;
$data[$cols_inc][‘FORMAT’]=‘N’;

for($c = 0; $c < count($data); ++$c)
{
echo $data[$c][‘VALUE’] ;
}

echo ‘
’;
echo ‘

’;
print_r($data);
echo ‘
’;

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service