mysqli prepared statements select *
Posted
by
Victor Dallecio
on Stack Overflow
See other posts from Stack Overflow
or by Victor Dallecio
Published on 2014-08-24T22:10:16Z
Indexed on
2014/08/24
22:20 UTC
Read the original article
Hit count: 370
I've spent this sunday trying to find what is wrong to the following code as it is not counting the rows. Could somebody help me with it? Thanks!
/*check if same IP has visited today*/
if ($stmt = $mysqli->query('SELECT * FROM table WHERE colum1 = ? AND colum2 > DATE_SUB(NOW(), INTERVAL 1 DAY)')) {
$stmt->bind_param('s', $ip);
/* execute query */
$stmt->execute();
/*number of rows */
/*store result when using prepared statements*/
$stmt->store_result();
$row_cnt = $stmt->num_rows;
printf("Result set has %d rows.\n", $row_cnt);
$stmt->close();
}
© Stack Overflow or respective owner