Jump to content

Warning: array_search() [function.array-search]: Wrong datatype for second argum


bugfinder

Recommended Posts

hello everybody, i have a issue with my code i tried to figured it out but i couldn't can any one check this for me, any help will be greatly appreciated

i attached code for u guys please help me out

requirements using :-

php:-  5.2.0

apache:-2.0.59.200

mysql :- 5.0.27

 

error:- Warning: array_search() [function.array-search]: Wrong datatype for second argument in C:\wamp\www\admin\admin_issue_emergency.php on line 34

 

 

here is the code :-

 

<?php
include('checkpoweredusersession.php');
include('config.php');
include('connect.php');
include('getmodules.php');

if (strpos($HTTP_REFERER,'admin_issue_emergency.php') == FALSE)
{
$_SESSION['roomList'] = NULL;
$selfCall = 1;
}
else
$selfCall = 0;

global $roomList;
if ($action =='add')
{
$count = count ($target_list);
for ($i =0; $i<$count ; $i++)
{
$roomList[] = $target_list[$i];
$allocatedTerminals[] = $target_list[$i];
}
$_SESSION['roomList'] = $roomList;
if ($_SESSION['roomList'])
$_SESSION['roomList'] = array_unique($_SESSION['roomList']);
}
if ($action =='remove')
{

$count = count ($allocatedTerminals);
for ($i =0; $i<$count ; $i++)
{
$key = array_search($allocatedTerminals[$i], $_SESSION['roomList']);
unSet($_SESSION['roomList'][$key]);
$_SESSION['roomList'][$key] = '';
$key = 0;
}
$_SESSION['roomList'] = array_trim($_SESSION['roomList']);

}
$roomList = $_SESSION['roomList'];

if ($action =='btnSend')
{
$pause = 5;
$sqlMsg = "SELECT * ".$DBTablesPrefix."_emergency_type";
$Infos = mysql_query($sqlMsg) or die("Query Failed 55");
$j = 0;
while($Row_Infos = mysql_fetch_assoc($Infos))
{
$j++;
$Id =$Row_Infos["Id"];
$msg =$Row_Infos["name"];
if ($Id == $name)
{
$display_message = $msg;
}
}
$commandURL = "../unrestricted/simple_remote_control.php4?message=".urlencode(stripslashes($display_message));
$cmdOptions = "/PASSWORD \"".$aminoRemoteControlPassPhrase."\" /TIMEOUT 12 /THREADS 60 /PAUSE ".$pause." /QUIET";

//integration of STBremoteConf
$cmdCommand = "/LOADURL ".$FULL_UNRESTRICTED_PATH."simple_emergency_message.php4"."?message=".urlencode(stripslashes($display_message));
$cmdFile = "/FILE \"".$tIpListFiles[$TERM_TYPE_AMINET100][0]."\"";
if ($target_type == 'all')
{
$sqlTerminals ="SELECT IP, Room FROM ".$DBTablesPrefix."_stbs "." WHERE (Version='AMINET110') "." ORDER BY (Room+0)";
$Infos = mysql_query($sqlTerminals) or die("Query Failed 76");
$i= 0;
while($Row_Infos = mysql_fetch_assoc($Infos))
{
$i++;
$termIP = $sqlTerminals->getRecord("IP", $i);
$termRoom = $sqlTerminals->getRecord("Room", $i);
$cmdLine = "..\\bin\\AminoBatchControl.exe ".$cmdCommand." ".$cmdOptions." ".' TERMINALCHANGE '.$termIP;
exec( $cmdLine, $cmdOutput);
}
$termCount = $i;
}
else if ($target_type == 'room')
{

for ($i = 0; $i< count($roomList); $i++)
{
$sqlTerminals = "SELECT IP, Room FROM ".$DBTablesPrefix."_stbs "." WHERE Room = '$roomList[$i]'";
$Infos = mysql_query($sqlTerminals) or die("Query Failed 94");
while($Row_Infos = mysql_fetch_assoc($Infos))
if ($i > 0)
{
$IP_terminal = $Row_Infos["IP"];

$cmdLine = "..\\bin\\AminoBatchControl.exe ".$cmdCommand." ".$cmdOptions." ".' TERMINALCHANGE '.$IP_terminal;
//echo $cmdLine;
exec( $cmdLine, $cmdOutput );
}
}
}
}

if (!isset($target_type))
$target_type = 'all';
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
Base1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: none;
color: #663300;
}
-->
</style>
<script language="javascript">
function disableItems(selectedItem)
{
if (selectedItem.value =='all')
{

document.getElementById("target_list").disabled = true;
document.getElementById("allocatedTerminals").disabled = true;
}

else if (selectedItem.value =='room')
{
document.getElementById("target_list").disabled = false;
document.getElementById("allocatedTerminals").disabled = false;
}

}
window.onload=function()
{
var targetType = '<? echo $target_type;?>';
if (targetType =='all')
{
document.getElementById("target_list").disabled = true;
document.getElementById("allocatedTerminals").disabled = true;
}
else if (targetType =='room')
{
document.getElementById("target_list").disabled = false;
document.getElementById("allocatedTerminals").disabled = false;
}
}
</script>
<link href="hoteltv.css" rel="stylesheet" type="text/css">
</head>
<body background="img/bg.gif">
<table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="FFFFFF" >
<tr>
<td>
<?PHP include('head_servicesmanagement.php'); ?>
</td>
</tr>
<tr ><td colspan="">
<?php
echo'<p align="center"><font color="#666666" size="4" face="Verdana, Arial, Helvetica, sans-serif">' ;
echo "Issue Emergency";
echo'</font></p>';

?>
</td></tr>
<tr><td>
<form method='get' name='form_allocate_terminals'>
<table border="0" cellpadding="1" cellspacing="0" width="50%" align="center" class="tableForm">

<tr>
<td>
<table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
<tr>
<td align="left" valign="middle" width="3%" ><font size="2">
Type:</font>
</td>
<td align="left" valign="middle" colspan="3">
<select name="message" >
<?
$sqlMsg = "SELECT * FROM ".$DBTablesPrefix."_emergency_type";
$Infos = mysql_query($sqlMsg) or die("Query failed on line 156");
$j = 0;
while($Row_Infos = mysql_fetch_assoc($Infos))
{
$j++;
$type_ID = $Row_Infos["Id"];
$message = $Row_Infos["name"];
echo "<option value='".$type_ID."' ".$strSelected.">".$message;
}
?>
</select>
</td>
</tr>
<tr>
<td align="left" valign="middle" width="3%" colspan="4">
<input type="radio" name="target_type" value="all" <?=($target_type=="all")?"checked":""?> onClick="disableItems(this);">
<font size="2">All:</font> </td>
</tr>

<tr>
<td align="left" valign="middle" width="3%" colspan="4">
<input type="radio" name="target_type" value="room" <?=($target_type=="room")?"checked":""?> onClick="disableItems(this);">
<font size="2">Rooms:</font></td>
</tr>
<tr>
<td></td>
<td align="left" valign="middle" width="10%">

<select name="target_list[]" id ='target_list' size="3" multiple onChange="/*document.form_allocate_terminals.target_type[0].checked=true*/">
<?
//terminal identification in multi-terminal rooms
$sqlTerminals ="SELECT IP, Room FROM ".$DBTablesPrefix."_stbs "." WHERE (Version='aminet110') "." ORDER BY (Room+0)";
$Infos = mysql_query($sqlTerminals) or die("Query failed on line 188");
$i = 0;
while($Row_Infos = mysql_fetch_assoc($Infos))

{
$i++;
$termIP = $Row_Infos["IP"];
$termRoom = $Row_Infos["Room"];
$messRoom = Room; //Room

//terminal identification in multi-terminal rooms
if ($roomList)
{
//$key = array_search($termRoom, $roomList); // $key = 2;
$key = in_array($termRoom, $roomList);
}
//echo 'R '. $termRoom . $key." k
";
if ($key != true)
echo "<option value='".$termRoom."' ".$strSelected.">$messRoom ".$termRoom." \r\n";
$termCount = $i;
}
?>
</select>

</td>
<td width="10%" class="light" align="center" valign="middle">
<input type="hidden" name="action" value="add">
<table border="0">
<tr align="center" height="50%">
<td width="30%">
<?
echo '<img src="../admin/img/right.gif" border="0"><img src="../admin/img/right.gif" border="0">';
?>
</td>
<td><input type="submit" onClick="document.form_allocate_terminals.action.value='add'; return true;" value="Add"></td>
<td width="30%">
<?
echo '<img src="../admin/img/right.gif" border="0"><img src="../admin/img/right.gif" border="0">';
?>
</td>
</tr>
<tr align="center" height="50%">
<td width="30%">
<?
echo '<img src="../admin/img/left.gif" border="0"><img src="../admin/img/left.gif" border="0">';
?>
</td>
<td><input type="submit" onClick="document.form_allocate_terminals.action.value='remove'; return true;" value="Remove"></td>
<td width="30%">
<?
echo '<img src="../admin/img/left.gif" border="0"><img src="../admin/img/left.gif" border="0">';
?>
</td>
</tr>
</table>
</td>
<td width="30%">
<select name="allocatedTerminals[]" id='allocatedTerminals' size="3" multiple onDblClick="document.form_allocate_terminals.action.value='remove'; document.form_allocate_terminals.submit();">
<?
$termCount = count($roomList);
for ($i = 0; $i < $termCount; $i++)
{
$termRoom = $roomList[$i];
$messRoom = Room; //ROOM
echo "<option value='".$termRoom."' ".$strSelected.">$messRoom ".$termRoom." \r\n";
}
?>
</select>
</td>
</tr>

<tr>
<td colspan="4" align="center"><input type="submit" name='btnSend' value="Send"></td>
</tr>
</table>
</td>
</tr>
</table>

</form>
<tr><td><?PHP include('tail.php'); ?></td></tr>
</td></tr>
</table>
</body>
</html>
<?
/**
* Trims an array from empty elements.
*
* @param $a the array to trim.
* @return a new array with the empty elements removed.
*/
function array_trim($a)
{
$j = 0;
for ($i = 0; $i < count($a); $i++)
{
if ($a[$i] != "")
{
$b[$j++] = $a[$i];
}
}
return $b;
}
?>

 

[attachment deleted by admin]

i checked what u told ..

 

Obviously, $_SESSION['roomList'] is not an array.

 

this happens when i try to remove the room number from the second box "allocatedTerminals"

but this

$roomList[]				= $target_list[$i];

have to assign the value to the roomlist

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.