tags:

views:

21

answers:

1

$query = 'SELECT COUNT(*) FROM Security WHERE ips=$currentip';

How do i get this to count the $currentip values that i make the variable equal to.

+1  A: 

assuming you're using the mysqli function set:

$mysqli=new mysqli('localhost', 'my_user', 'my_password', 'my_db');

$query = 'SELECT COUNT(*) as num FROM Security WHERE ips=$currentip';
$response=$mysqli->query($query);
$row=$response->fetch_assoc();
$count=$row['num'];

It would be preferable to clean $currentip. Or even better to use a prepared statement.

dnagirl