Home > Article > Backend Development > php bind_param有关问题,新手求教
php bind_param问题,新手求教
刚刚学到prepared这儿,敲了如下代码
<br />$db = new mysqli("localhost", "xx","xxxxxxx","books");<br /> $insert_str = "insert into customers(name,address,city) values(?,?,?)";<br /> $stmt = $db->prepare($insert_str);<br /> $stmt->bind_param("sss","john","street one","beijing");<br /> $stmt->execute();<br /> echo $stmt->affected_rows;<br />
<br />$db = new mysqli("localhost", "xx","xxxxxx","books");<br /> $insert_str = "insert into customers(name,address,city) values(?,?,?)";<br /> $stmt = $db->prepare($insert_str);<br /> $name ="john";<br /> $address = "street one";<br /> $city = "beijing";<br /> $stmt->bind_param("sss",$name,$address,$city);<br /> $stmt->execute();<br /> echo $stmt->affected_rows;<br />