I have a marquee displaying mysql data. The marquee works perfectly but I get:
Notice: Undefined variable: cont in include() (line 51)
Here is the code I am using.
while($row = mysql_fetch_array($result))
{
$fundid=$row['Fund_ID'];
$fundname=$row['Fund_Name'];
$mostrecentnav=$row['Most_Recent_Nav'];
$lastdaychange=$row['Last_Day_Change'];
$lastdayyield=$row['Last_Day_Yield'];
$cont.= "<a style='color:#0066CC;' href=\"fund-?id=$fundid\">$fundname</a> <b>NAV:</b>$mostrecentnav, <b>Cambio del nav en el dia:</b>$lastdaychange, $lastdayyield% ";
}
echo "<marquee scrollamount='3' scrolldelay='1' onmouseover='this.stop();' onmouseout='this.start();'>$cont</marquee>";
mysql_close($con);
What needs to be changed to get rid of the error. The variable is defined otherwise the query wouldn't work. Thank you.
$cont = '';
before the while() loop will fix that. you're implicitly USING $cont before it's been set, the first time you execute:
$cont .= ...;
which is equivalent to
$cont = $cont . ....;
^^^^^---undefined on first iteration.