<?php
$get_user="SELECT privillage FROM admin_user WHERE id='".$_SESSION['user_id']."'";
// echo $get_user;
$exe_query=mysql_query($get_user);
$row=mysql_fetch_array($exe_query);
$privillage_data = unserialize($row['privillage']);
//print_r($privillage_data);
//$privillage_data1=explode(",",$privillage_data);
echo '<pre>';
print_r($privillage_data);
$count=count($privillage_data);
//echo "Count".$count;
if($privillage_data[0] == '1' || $privillage_data[1] == '1' || $privillage_data[2] == '1' && $count >=1)
{
$priv_add ="true";
echo "add--".$priv_add."</br>";
}
else{$priv_add ="false";}
if($count >=2 && $privillage_data[1] == '2' || $privillage_data[0] == '2' || $privillage_data[2] == '2')
{
$priv_edit ="true";
echo "edit--".$priv_edit."</br>";
}
else{$priv_edit ="false";}
if($count ==3 && $privillage_data[2] == '3' || $privillage_data[0] == '3' || $privillage_data[1] == '3')
{
$priv_delete ="true";
echo "delete--".$priv_delete."</br>";
}
else{$priv_delete ="false";}
&GT;
当使用上面的代码时,我在 if 条件下得到未定义的偏移误差!! 如何解决胶印问题!! 需要帮助!!请让我简单
答案 0 :(得分:3)
看起来你有数组索引的空值
尝试使用isset()
或empty()
isset($privillage_data[0])
或!empty($privillage_data[0])
等等...对于所有索引
所以你的病情将是
if((!empty($privillage_data[0]) && $privillage_data[0] == '1') || (!empty($privillage_data[1]) && $privillage_data[1] == '1') || (!empty($privillage_data[2]) && $privillage_data[2] == '1') && $count >=1)
对于您正在使用的所有条件等等
答案 1 :(得分:1)
转储privillage_data的内容。你错过了一个阵列密钥,这是你期待的。另外,上面哪一行给出错误?