I am trying to get a number of rows providing the user id's in $admin_ID are not present.
$admin_ID = "1, 32, 34";
foreach($con->query('SELECT user_agent FROM wp_access_log WHERE user_id NOT IN ($admin_ID)') as $row2) {
$user_agent2 = $row2['user_agent'];
$browser2 = new BrowserDetection();
$browser2->setUserAgent($user_agent2);
$browserName2 = $browser2->getPlatform(); //string
$browserNameString2[] = $browserName2;
}
$string = var_export(array_count_values($browserNameString2), true);
echo "<table id='datatable-buttons' class='table table-striped table-bordered dt-responsive' cellspacing='0' width='100%'>";
echo "<tr><td><b>Browser</b></td><td><b>Visits</b></td></tr>";
$string = str_replace("array (","",$string);
$string = str_replace("' => ","</td><td>",$string);
$string = str_replace(",","</td></tr>",$string);
$string = str_replace(")","",$string);
$string = str_replace("'","<tr><td>",$string);
$string = $string . "</table>";
echo $string;
I get the following error:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\account-stats.php on line 543
Notice: Undefined variable: browserNameString2 in C:\xampp\htdocs\account-stats.php on line 553
Warning: array_count_values() expects parameter 1 to be array, null given in C:\xampp\htdocs\account-stats.php on line 553 NULL
If I remove the code:
WHERE user_id NOT IN ($admin_ID)
Then the code runs fine and loads all records from the database.
Can I get a pointer as to what I have done wrong here?