MySQL Forums
Forum List  »  PHP

Mysqli Error for Count (Distinct) Query
Posted by: Eric Hilding
Date: May 13, 2019 07:39PM

Probably something very simple, but I cannot figure it out. Any help is greatly appreciated !!!

*** I am trying to just get a simple COUNT of all "Unique" Last Names in the 'lastname' column.

(ERROR)

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given...(in this line of code: $count = mysqli_fetch_array($result);)

(QUERY)

$sql = "SELECT COUNT (DISTINCT lastname) FROM contacts";

$result = mysqli_query($con,$sql);

$count = mysqli_fetch_array($result);

$uniques = $count[0];

echo $uniques . "Total Uniques";

Thank you very much.

-Eric

Options: ReplyQuote


Subject
Written By
Posted
Mysqli Error for Count (Distinct) Query
May 13, 2019 07:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.