Hi all:
2 problems for the price of 1!
The following code allows the SQL to parse but does not follow the command if the results are "0".
$row_cnt = mysqli_num_rows($stmt);
echo $row_cnt;
if ($row_cnt===0){
echo "<tr><td colspan='12'>No records returned</td></tr>";
Whereas the following will never parse the SQL and always returns "No records returned" (Note only == instead of ===):
$row_cnt = mysqli_num_rows($stmt);
echo $row_cnt;
if ($row_cnt==0){
echo "<tr><td colspan='12'>No records returned</td></tr>";
The other problems with the query is the mysqli_error. the SQL can parse fine but I continue to get "Commands out of sync; you can't run this command now"
Here is the complete code to show the placement of the mysqli_error:
if ($stmt = mysqli_prepare($link, "
SELECT
events.eID,
events.player,
events.promoter,
FROM
events INNER JOIN promoters on promoters.promoter = events.promoter
WHERE
promoters.prID=? ORDER BY $qOB"
)) {
mysqli_stmt_bind_param($stmt, "s", $qPrID);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,
$rEid,
$rPlayer,
$rPromoter,
);
if (!mysqli_query($link, "SET a=1")) {
printf("Errormessage: %s\n", mysqli_error($link));
}
$row_cnt = mysqli_num_rows($stmt);
echo $row_cnt;
if ($row_cnt===0){
echo "<tr><td colspan='12'>No records returned</td></tr>";
} else {
while (mysqli_stmt_fetch($stmt)) {
echo "<tbody class='tdbody results'>\r\n";
echo "<tr>\r\n";
echo "<td class='tdresults'><a href = 'admEventsUpdate2.php?eID=" . $rEid . "&player=" . $rPlayer ." &promoter=" . $rPromoter . "'>Update</a></td>\r\n";
echo "<td class='tdresults'><a href = '../del/delResults.php?eID=" . $rEid ."'>". $rPlayer. "</a></td>\r\n";
echo "<td class='tdresults'>" . $rPromoter . "</td>\r\n";
echo "</tr>\r\n";
echo "</tbody>\r\n";
}
mysqli_stmt_close($stmt);
}
}
mysqli_close($link);
?>
THANK YOU!