Posted by gerg on 12/15/05 02:04
I have an odd thing happening. Can you reference variable that are set
above a function? The below code is not working for me:
<?
$sql ="some sql query";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$msg = nl2br($row['message']);
function mycontent(){
?>
Some html code............
<?
echo $msg;
?>
Some more html code.......
<?
}
?>
However this does work:
function mycontent(){
?>
Some html code............
<?
$sql ="some sql query";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$msg = nl2br($row['message']);
echo $msg;
?>
Some more html code.......
<?
}
?>
Any reason why it works when the variables are inside the function as
opposed to being outside of it? Thanks!
Greg
Navigation:
[Reply to this message]
|