$params
이라는 배열로 준비된 명령문을 생성하고 싶습니다. 내 스크립트를 실행할 때 다음과 같은 오류 얻을 :준비된 명령문의 배열이 작동하지 않습니다.
Fatal error: Call to a member function bind_param() on a non-object in /home/morea/directory-new.php on line 110
라인 110) ($stmt->bind_param('i', $place_holders);
$params = array(5, 6, 7, 9, 10, 11, 12, 3, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 4, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42);
/* Create a string for the parameter placeholders filled to the number of params */
$mysqli = new MySQLi("localhost", "erpa", "48p", "le3");
$mysqli->set_charset('utf8');
$place_holders = implode(',', array_fill(0, count($params), '?'));
$sth = ("SELECT u.url, COUNT(u.url) AS total, u.SiteTypeID, p.SiteType FROM sites AS u LEFT JOIN sitetypes AS p USING (SiteTypeID) WHERE SiteTypeID=($place_holders)");
$stmt = $mysqli->prepare($sth);
$stmt->bind_param('i', $place_holders);
$stmt->execute($params);
$query5 = mysqli_query($dbc, $sth);
while($row2 = mysqli_fetch_array($sql3, MYSQLI_ASSOC) && $row4 = mysqli_fetch_array($query5, MYSQLI_ASSOC)){
if ($row4['SiteType'] == 'selected'){
$list .= $row4['total'];
$list .= '<option value="'.$row4['SiteTypeID'].'"';
$list .= "selected='selected'>";
$list .= $row4['SiteType'];
$list .= "</option>";
}
}
왜 mysqli_query ($ dbc, $ sth);가 있습니까? –
fetch_array를 내 sql 문과 함께 사용 하시려면 – user3286022
그건 mysqli_query를 올바르게 사용하지 않았습니다. –