开发者

Whats wrong with this prepared statement

开发者 https://www.devze.com 2023-03-16 02:17 出处:网络
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

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消