Hello how to fix it guys?

Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\admin\index.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\admin\index.php on line 285

Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\admin\index.php on line 286

Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\admin\index.php on line 287

    Make whatever is inside the count function an array or Countable object? 😉

    Or, if you want to tell count to count($something_uncountable) I guess you could turn warnings off?

    Whichever way, you'll not get much help until some code shows up ...

      these 4 things have warning:

      		$newsTitle[ count( $newsTitle ) ] = $tmp[ 0 ];
      		$newsText[ count( $newsText ) ] = $tmp[ 1 ];			
      		$newsDate[ count( $newsDate ) ] = $tmp[ 2 ];	
      		$newsApproval[ count( $newsApproval ) ] = $tmp[ 3 ];

        So have you verified that all of those variables are arrays (or for that matter objects that implement ArrayAccess as well as Countable)? Where do they come from? How are they created?

        Incidentally, if you're just using count($newsTitle) to put an element on the end of the $newsTitle array, you might not need to.

        Given the names of the variables you're using, I assume that you're trying to count a string. Maybe strlen() is what you're looking for, assuming there's actually a need or reason to do it this way? As Weedpacket Weedpacket pointed out, you probably don't have to do that...

          Are you assigning variables inside a loop?

          $counter = 0;
          
          while ($tmp = some_data_thingy()) {
          
              $newsTitle[$counter]    = $tmp[0];
              $newsText[$counter]     = $tmp[1];			
              $newsDate[$counter]     = $tmp[2];	
              $newsApproval[$counter] = $tmp[3];
              $counter++;
          }

          If so, even if you can get count() to work, that's a lot of extra overhead to put in a loop.

            Write a Reply...