what is the problem if i got this notice saying:
Notice: Undefined index: 8 in C:\xampp\htdocs\projects\wesm\intranet\plugins\survey_manager\index.php on line 80
i'm using the jquery autocomplete..
here is some of my code for javascript in which the error occurred:
<script type='text/javascript'>
var intranetUsers = ["<?php echo $content[0].' ", "';
$num = 1;
while($num != $getInranetUserCount['num']){
echo $content[$num].'" , "';
$num = $num + 1;
}
echo $content[$getInranetUserCount['num']];
?>"];
</script>
I've already use that code in some module and it works I don't know why it doesn't work this time.
var intranetUsers = ["<?php echo $content[0].' ", "';
Would definitely error out. Without knowing the value of either $content or $getInranetUserCount, I'm not sure what you're trying to do here. Perhaps a better question would be explaining what you're trying to do than just giving a small snippet that none of us are going to understand without context.
Your $content
array is most likely missing an entry for $num == 8
. You'll find the source of your problem elsewhere in your application.
In general, it's a bad idea to inline PHP with Javascript this way. Consider at the very least breaking it up:
<?php
// Start capturing output to buffer
ob_start();
// Create string
echo $content[0].' ", "';
$num = 1;
while($num != $getInranetUserCount['num']){
echo $content[$num].'" , "';
$num = $num + 1;
}
echo $content[$getInranetUserCount['num']];
// Get output from buffer
$out = ob_get_contents();
// End buffering
ob_end_clean();
?>
<script type='text/javascript'>
var intranetUsers = ["<?php echo $out ?>"];
</script>