scope issue
Posted: Fri Jan 24, 2003 11:17 am
I admit that I"m rather new at this ... but not to programming ... and this is confusing me...
in the following the fist echo statment yeilds "chaos" --- this is good ... the second yeilds "=" or a char similar --- this is confusing as it's global ... or am I missing something? ( code snipped )
thanks
in the following the fist echo statment yeilds "chaos" --- this is good ... the second yeilds "=" or a char similar --- this is confusing as it's global ... or am I missing something? ( code snipped )
Code: Select all
<?php
include './lib/stdhtml.php';
include './lib/sec.php';
global $db_name;
$db_name = "chaos";
htmlheader();
echo '$db_name = '.$db_name."<BR>";
function main(){
echo 'main start $db_name = '.$db_name."<BR>";
// code
}
function Auth( $argp = 0 ){
echo "<form Action='db_setup.php?cmd=start' Method=post>
";
if ( $argp ) { echo "<TR><TD align=center>Unable to locate username/password combination</TD></TR>"; }
else { $username = ''; }
echo '
<TR><TD align=center>Username: <input type"textbox" Value="'.$username.'" name=user_name></TD></TR>
<TR></TR><TR><TD align=center>Password: <input type"password" name=password></TD></TR>
<TR><TD><input type=submit>" "<input type="reset"></TD></TR>
</FORM>';
}
htmlfooter();
switch($_REQUESTї'cmd']){
case "start":
main();
break;
default:
Auth();
break;
}