php - How do I count rows in a table according to ID column (prepared statements)? -


i have array populated records 1 table , want count corresponding records table , insert array.

when try code keep getting error

warning: mysqli::prepare() [mysqli.prepare]: data must fetched before new statement prepare takes place

foreach ($persons $i=>$person) {      $stmt = $mysqli->prepare("select count(*) order personid = ?");     $stmt->bind_param("i", $person['personid']);     $stmt->execute();     $stmt->bind_result($totalorders);     $stmt->fetch();     $stmt->close;            $persons[$i]['totalorders'] = $totalorders; } 

it's though $stmt->close; being ignored.

you need add parentheses call close method:

$stmt->close(); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -