i have a prepared statement just learned few hours ago but i get always as return 0
$ip = $data
$stmt = $mysqli->prepare("SELECT counter_ip
FROM counter_out
WHERE counter_ip = ?");
$stmt->bind_param('s', $ip);
$stmt->execute;
$stmt->bind_result($r_ip);
$stmt->fetch();
echo "<pre>";
echo $r_ip;
echo "</pre>";
bind_result i tried all i d b s, But when i do it this way without prepared statement it works
$sql = "SELECT counter_ip
FROM counter_out
WHERE counter_ip = '$ip'";
$result = $mysqli->query($sql);
$dupecheck =开发者_开发问答 $result->fetch_assoc();
echo "<pre>";
echo $dupecheck[counter_ip];
echo "</pre>";
Do i have an error in the prepared statement?
$stmt->execute;
This is a method. It should be:
$stmt->execute();
$mysqli->prepare("SELECT counter_ip FROM counter_out WHERE counter_ip = :s");
精彩评论