- #1
jgg
- 40
- 0
PHP - "Wrong datatype for second argument"
So I build this class in my library file (assume that I have all the PHP tags and stuff)...
Where '$pb' is an array I have created, that gets assigned a new string given a certain set of conditions. Thus, I wanted to use this object to check for certain strings in an array, and if it's there print out another string.
Then on the main PHP page, I create an instance of the object and attempt to use it as such...
but it doesn't work, and I get slammed with
"Warning: in_array() [function.in-array]: Wrong datatype for second argument in directory on line xxxx"
Which points to my function errorsearch above. What am I doing wrong (it also does this if I just use a function)? This is my first time writing in PHP, so apologies if I missed something stupid.
So I build this class in my library file (assume that I have all the PHP tags and stuff)...
PHP:
class errorchecker {
var $error;
function errorsearch($error) {
if (in_array($error, $pb)){
echo '<div class="error">'.$error.'</div>';
}
}
}
Where '$pb' is an array I have created, that gets assigned a new string given a certain set of conditions. Thus, I wanted to use this object to check for certain strings in an array, and if it's there print out another string.
Then on the main PHP page, I create an instance of the object and attempt to use it as such...
PHP:
<?php
$one = new errorchecker;
$one -> errorsearch('String I want to be searched for');
?>
but it doesn't work, and I get slammed with
"Warning: in_array() [function.in-array]: Wrong datatype for second argument in directory on line xxxx"
Which points to my function errorsearch above. What am I doing wrong (it also does this if I just use a function)? This is my first time writing in PHP, so apologies if I missed something stupid.