Why is in_array() giving me an error?
Posted: Wed Oct 27, 2010 3:10 pm
Relevant code:
Receiving the following error message:
[text]
Notice: Undefined variable: cycle in C:\wamp\www\display3.php on line 41
Warning: in_array() expects parameter 2 to be array, null given in C:\wamp\www\display3.php on line 41
[/text]
var_dump() returns the array $cycle just fine. What am I missing?
Code: Select all
$cycle = array('Feb-10','May-10','Aug-10','Nov-10');
function printDate($customer) {
$query = "SELECT date FROM $customer ORDER BY date";
$result = mysql_query($query) OR die(mysql_error());
$num = mysql_num_rows($result);
$x = 0;
echo "<col />";
while($x < $num) {
$data = mysql_result($result,$x,'date');
$date = date('M-y',strtotime($data));
$colDate = (in_array($date,$cycle)) ? '<col style="border-left:solid 3px" />' : '<col />'; // Error here.
echo $colDate;
$x++;
}
[text]
Notice: Undefined variable: cycle in C:\wamp\www\display3.php on line 41
Warning: in_array() expects parameter 2 to be array, null given in C:\wamp\www\display3.php on line 41
[/text]
var_dump() returns the array $cycle just fine. What am I missing?