I have the php code as below:
<?php
$conn = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("dbcsv",$conn);
$data = array();
$sql = "select orig,dlvSourceIp from tblcsv group by dlvSourceIp";
$res = mysql_query($sql) or die(mysql_error());
echo '<table border="1px">';
echo "<tr><td>Dormain</td><td>ip of the domain</td><td>Total Mail</td><td>Mail Fail</td><td>Percentage</td></tr>";
while($data = mysql_fetch_array($res)){
//echo "<tr><td>".$data['orig']."</td><td>".$data['dlvSourceIp']."</td><td></td><td></td></tr>";
$t = $data['orig'];
$getData = array_unique($t);
var_dump($getData);
}
?>
Note
For $data['orig'] is the array of data that I select it from database it will display: cat cat dog cat dog. I want output like this:cat dog that why I use array unique.
The problem:
I got the error message array_unique() expects parameter 1 to be array, null given in C:\wamp\www\CountLine_CSV\csv2mysql.php on line 21 How do I fix it? Anyone help me please,Thanks.
array_uniqueinstead of a null value ... the error message is pretty clear. The value of$tin your code is quite obviously null.print_r($data['orig']). it appears as though the variable$data['orig']is not an array. It must be an array to use that function.origwill be?