Undefined variable
ประกาศค่าตัวแปรไว้ดังนี้
$sql = "SELECT status from tbjobunit WHERE unitid = '".$rowuser["workunit"]."'";
$resultunit = $db_conn->query ($sql);
$rowunit = mysql_fetch_array($resultunit);
session_register('myauth');
$myauth['userid'] = $row["userid"];
$myauth['userin'] = $row["empid"];
$myauth['empid'] = $row["empid"];
$myauth['ugroup'] = $row["ugroup"];
$myauth['ueditjob'] = $row["ueditjob"];
$myauth['prank'] = $rowuser["emprank"];
$myauth['pname'] = $rowuser["empname"];
$myauth['psname'] = $rowuser["empsname"];
$myauth['empflag'] = $rowuser["empflag"];
$myauth['pposition'] = $rowuser["workposition"];
$myauth['pworkunit'] = $rowuser["workunit"];
$myauth['workplace'] = $rowuser["workplace"];
$myauth['unitstatus'] = $rowunit["status"];
header("Location: main.php");
exit();
}
เมื่อโยนค่าไปอีกหน้า แสดง Error ว่าไม่รู้จักค่า myauth
PHP Notice: Undefined variable: myauth in D:\Inetpub\wwwroot\myphp\eOfficeCode\main.php on line 5
แสดงข้อมูลอีกหน้า
session_start();
echo $myauth['empid'];
เป็นเพราะอะไร
$sql = "SELECT status from tbjobunit WHERE unitid = '".$rowuser["workunit"]."'";
$resultunit = $db_conn->query ($sql);
$rowunit = mysql_fetch_array($resultunit);
session_register('myauth');
$myauth['userid'] = $row["userid"];
$myauth['userin'] = $row["empid"];
$myauth['empid'] = $row["empid"];
$myauth['ugroup'] = $row["ugroup"];
$myauth['ueditjob'] = $row["ueditjob"];
$myauth['prank'] = $rowuser["emprank"];
$myauth['pname'] = $rowuser["empname"];
$myauth['psname'] = $rowuser["empsname"];
$myauth['empflag'] = $rowuser["empflag"];
$myauth['pposition'] = $rowuser["workposition"];
$myauth['pworkunit'] = $rowuser["workunit"];
$myauth['workplace'] = $rowuser["workplace"];
$myauth['unitstatus'] = $rowunit["status"];
header("Location: main.php");
exit();
}
เมื่อโยนค่าไปอีกหน้า แสดง Error ว่าไม่รู้จักค่า myauth
PHP Notice: Undefined variable: myauth in D:\Inetpub\wwwroot\myphp\eOfficeCode\main.php on line 5
แสดงข้อมูลอีกหน้า
session_start();
echo $myauth['empid'];
เป็นเพราะอะไร
session_start(); แล้วหรือยังอะครับ